# Path: stestr/repository/file.py
# def atomicish_rename(source, target):
#     def initialise(klass, url):
#     def open(self, url):
#     def __init__(self, base):
#     def _allocate(self):
#     def _next_stream(self):
#     def count(self):
#     def latest_id(self):
#     def get_run_ids(self):
#     def remove_run_id(self, run_id):
#     def get_failing(self):
#     def _get_metadata(self, run_id):
#     def get_test_run(self, run_id):
#     def _get_inserter(self, partial, run_id=None, metadata=None):
#     def _get_test_times(self, test_ids):
#     def _path(self, suffix):
#     def _write_next_stream(self, value):
#     def find_metadata(self, metadata):
#     def __init__(self, run_id, subunit_content, metadata=None):
#     def get_id(self):
#     def get_subunit_stream(self):
#     def get_test(self):
#         def wrap_result(result):
#     def get_metadata(self):
#     def __init__(self, repository, partial=False, run_id=None, metadata=None):
#     def _handle_test(self, test_dict):
#     def startTestRun(self):
#     def stopTestRun(self):
#     def status(self, *args, **kwargs):
#     def _cancel(self):
#     def get_id(self):
#     def _name(self):
#     def _name(self):
#     def stopTestRun(self):
# class RepositoryFactory(repository.AbstractRepositoryFactory):
# class Repository(repository.AbstractRepository):
# class _DiskRun(repository.AbstractTestRun):
# class _SafeInserter:
# class _FailingInserter(_SafeInserter):
# class _Inserter(_SafeInserter):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import os.path
import shutil
import tempfile
import fixtures
import testtools
from testtools import matchers
from stestr.repository import file
from stestr.tests import base
        self.assertTrue(os.path.isfile(os.path.join(base, 'format')))
        with open(os.path.join(base, 'format')) as stream:
            contents = stream.read()
        self.assertEqual("1\n", contents)
        with open(os.path.join(base, 'next-stream')) as stream:
            contents = stream.read()
        self.assertEqual("0\n", contents)

    def test_initialise_non_empty_dir(self):
        self.useFixture(FileRepositoryFixture(path=self.tempdir,
                                              initialise=False))
        base = os.path.join(self.tempdir, '.stestr')
        os.mkdir(base)
        with open(os.path.join(base, 'foo'), 'wt') as stream:
            stream.write('1\n')
        factory = file.RepositoryFactory()
        self.assertRaises(OSError, factory.initialise, self.tempdir)

    # Skip if windows since ~ in a path doesn't work there
    @testtools.skipIf(os.name == 'nt', "Windows doesn't support '~' expand")
    def test_initialise_expands_user_directory(self):
        short_path = self.useFixture(HomeDirTempDir()).short_path
        repo = file.RepositoryFactory().initialise(short_path)
        self.assertTrue(os.path.exists(repo.base))

    def test_inserter_output_path(self):
        repo = self.useFixture(FileRepositoryFixture()).repo
        inserter = repo.get_inserter()
        inserter.startTestRun()
        inserter.stopTestRun()

# Path: stestr/repository/file.py
# def atomicish_rename(source, target):
#     def initialise(klass, url):
#     def open(self, url):
#     def __init__(self, base):
#     def _allocate(self):
#     def _next_stream(self):
#     def count(self):
#     def latest_id(self):
#     def get_run_ids(self):
#     def remove_run_id(self, run_id):
#     def get_failing(self):
#     def _get_metadata(self, run_id):
#     def get_test_run(self, run_id):
#     def _get_inserter(self, partial, run_id=None, metadata=None):
#     def _get_test_times(self, test_ids):
#     def _path(self, suffix):
#     def _write_next_stream(self, value):
#     def find_metadata(self, metadata):
#     def __init__(self, run_id, subunit_content, metadata=None):
#     def get_id(self):
#     def get_subunit_stream(self):
#     def get_test(self):
#         def wrap_result(result):
#     def get_metadata(self):
#     def __init__(self, repository, partial=False, run_id=None, metadata=None):
#     def _handle_test(self, test_dict):
#     def startTestRun(self):
#     def stopTestRun(self):
#     def status(self, *args, **kwargs):
#     def _cancel(self):
#     def get_id(self):
#     def _name(self):
#     def _name(self):
#     def stopTestRun(self):
# class RepositoryFactory(repository.AbstractRepositoryFactory):
# class Repository(repository.AbstractRepository):
# class _DiskRun(repository.AbstractTestRun):
# class _SafeInserter:
# class _FailingInserter(_SafeInserter):
# class _Inserter(_SafeInserter):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/repository/test_file.py
import os.path
import shutil
import tempfile
import fixtures
import testtools
from testtools import matchers
from stestr.repository import file
from stestr.tests import base

        self.assertTrue(os.path.isfile(os.path.join(base, 'format')))
        with open(os.path.join(base, 'format')) as stream:
            contents = stream.read()
        self.assertEqual("1\n", contents)
        with open(os.path.join(base, 'next-stream')) as stream:
            contents = stream.read()
        self.assertEqual("0\n", contents)

    def test_initialise_non_empty_dir(self):
        self.useFixture(FileRepositoryFixture(path=self.tempdir,
                                              initialise=False))
        base = os.path.join(self.tempdir, '.stestr')
        os.mkdir(base)
        with open(os.path.join(base, 'foo'), 'wt') as stream:
            stream.write('1\n')
        factory = file.RepositoryFactory()
        self.assertRaises(OSError, factory.initialise, self.tempdir)

    # Skip if windows since ~ in a path doesn't work there
    @testtools.skipIf(os.name == 'nt', "Windows doesn't support '~' expand")
    def test_initialise_expands_user_directory(self):
        short_path = self.useFixture(HomeDirTempDir()).short_path
        repo = file.RepositoryFactory().initialise(short_path)
        self.assertTrue(os.path.exists(repo.base))

    def test_inserter_output_path(self):
        repo = self.useFixture(FileRepositoryFixture()).repo
        inserter = repo.get_inserter()
        inserter.startTestRun()
        inserter.stopTestRun()

        self.assertTrue(os.path.exists(os.path.join(repo.base, '0')))