# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import os
import shutil
import subprocess
import tempfile
from stestr.tests import base

class TestBisectReturnCodes(base.TestCase):
    def setUp(self):
        super().setUp()
        # Setup test dirs
        self.directory = tempfile.mkdtemp(prefix='stestr-unit')
        self.addCleanup(shutil.rmtree, self.directory)
        self.test_dir = os.path.join(self.directory, 'tests')
        os.mkdir(self.test_dir)
        # Setup Test files
        self.testr_conf_file = os.path.join(self.directory, '.stestr.conf')
        self.setup_cfg_file = os.path.join(self.directory, 'setup.cfg')
        self.init_file = os.path.join(self.test_dir, '__init__.py')
        self.setup_py = os.path.join(self.directory, 'setup.py')
        self.user_config = os.path.join(self.directory, 'stestr.yaml')
        shutil.copy('stestr/tests/files/testr-conf', self.testr_conf_file)
        shutil.copy('setup.py', self.setup_py)
        shutil.copy('stestr/tests/files/setup.cfg', self.setup_cfg_file)
        shutil.copy('stestr/tests/files/__init__.py', self.init_file)
        shutil.copy('stestr/tests/files/stestr.yaml', self.user_config)

        # Move around the test code
        self.serial_fail_file = os.path.join(self.test_dir,
                                             'test_serial_fails.py')
        shutil.copy('stestr/tests/files/bisect-fail-serial-tests',
                    self.serial_fail_file)

        # Change directory, run wrapper and check result
        self.addCleanup(os.chdir, os.path.abspath(os.curdir))
        os.chdir(self.directory)

# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/test_bisect_return_codes.py
import os
import shutil
import subprocess
import tempfile
from stestr.tests import base


class TestBisectReturnCodes(base.TestCase):
    def setUp(self):
        super().setUp()
        # Setup test dirs
        self.directory = tempfile.mkdtemp(prefix='stestr-unit')
        self.addCleanup(shutil.rmtree, self.directory)
        self.test_dir = os.path.join(self.directory, 'tests')
        os.mkdir(self.test_dir)
        # Setup Test files
        self.testr_conf_file = os.path.join(self.directory, '.stestr.conf')
        self.setup_cfg_file = os.path.join(self.directory, 'setup.cfg')
        self.init_file = os.path.join(self.test_dir, '__init__.py')
        self.setup_py = os.path.join(self.directory, 'setup.py')
        self.user_config = os.path.join(self.directory, 'stestr.yaml')
        shutil.copy('stestr/tests/files/testr-conf', self.testr_conf_file)
        shutil.copy('setup.py', self.setup_py)
        shutil.copy('stestr/tests/files/setup.cfg', self.setup_cfg_file)
        shutil.copy('stestr/tests/files/__init__.py', self.init_file)
        shutil.copy('stestr/tests/files/stestr.yaml', self.user_config)

        # Move around the test code
        self.serial_fail_file = os.path.join(self.test_dir,
                                             'test_serial_fails.py')
        shutil.copy('stestr/tests/files/bisect-fail-serial-tests',
                    self.serial_fail_file)

        # Change directory, run wrapper and check result
        self.addCleanup(os.chdir, os.path.abspath(os.curdir))
        os.chdir(self.directory)

        subprocess.call('stestr init', shell=True)