# Path: stestr/repository/util.py
# def _get_default_repo_url(repo_type):
# def get_repo_open(repo_type, repo_url=None):
# def get_repo_initialise(repo_type, repo_url=None):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import os
import shutil
import tempfile
from unittest import mock
from stestr.repository import util
from stestr.tests import base
        self.addCleanup(os.chdir, cwd)

    def test_get_default_url_sql(self):
        repo_url = util._get_default_repo_url('sql')
        self.assertEqual('sqlite:///' + os.path.join(self.temp_dir,
                                                     '.stestr.sqlite'),
                         repo_url)

    def test_get_default_url_file(self):
        repo_url = util._get_default_repo_url('file')
        self.assertEqual(self.temp_dir, repo_url)

    def test_get_default_url_invalid_type(self):
        self.assertRaises(TypeError, util._get_default_repo_url,
                          'invalid_type')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_sql_get_repo_init_no_deps(self, import_mock):
        self.assertRaises(SystemExit, util.get_repo_initialise, 'sql')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_non_sql_get_repo_init_no_deps_import_error(self, import_mock):
        self.assertRaises(ImportError, util.get_repo_initialise, 'file')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_sql_get_repo_open_no_deps(self, import_mock):
        self.assertRaises(SystemExit, util.get_repo_open, 'sql')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_non_sql_get_repo_open_no_deps_import_error(self, import_mock):

# Path: stestr/repository/util.py
# def _get_default_repo_url(repo_type):
# def get_repo_open(repo_type, repo_url=None):
# def get_repo_initialise(repo_type, repo_url=None):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/repository/test_util.py
import os
import shutil
import tempfile
from unittest import mock
from stestr.repository import util
from stestr.tests import base

        self.addCleanup(os.chdir, cwd)

    def test_get_default_url_sql(self):
        repo_url = util._get_default_repo_url('sql')
        self.assertEqual('sqlite:///' + os.path.join(self.temp_dir,
                                                     '.stestr.sqlite'),
                         repo_url)

    def test_get_default_url_file(self):
        repo_url = util._get_default_repo_url('file')
        self.assertEqual(self.temp_dir, repo_url)

    def test_get_default_url_invalid_type(self):
        self.assertRaises(TypeError, util._get_default_repo_url,
                          'invalid_type')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_sql_get_repo_init_no_deps(self, import_mock):
        self.assertRaises(SystemExit, util.get_repo_initialise, 'sql')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_non_sql_get_repo_init_no_deps_import_error(self, import_mock):
        self.assertRaises(ImportError, util.get_repo_initialise, 'file')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_sql_get_repo_open_no_deps(self, import_mock):
        self.assertRaises(SystemExit, util.get_repo_open, 'sql')

    @mock.patch('importlib.import_module', side_effect=ImportError)
    def test_non_sql_get_repo_open_no_deps_import_error(self, import_mock):

        self.assertRaises(ImportError, util.get_repo_open, 'file')