9 from cola
import gitcfg
10 from cola
import gitcmds
14 """Returns a path relative to the test/tmp directory"""
15 return os
.path
.join(os
.path
.dirname(__file__
), 'tmp', *paths
)
19 return os
.path
.join(os
.path
.dirname(__file__
), 'fixtures', *paths
)
28 out
= core
.read_nointr(p
).strip()
33 class TmpPathTestCase(unittest
.TestCase
):
35 self
._testdir
= tempfile
.mkdtemp('_cola_test')
36 os
.chdir(self
._testdir
)
39 """Remove the test directory and return to the tmp root."""
46 self
.failIf(result
!= 0)
48 def test_path(self
, *paths
):
49 return os
.path
.join(self
._testdir
, *paths
)
52 class GitRepositoryTestCase(TmpPathTestCase
):
53 """Tests that operate on temporary git repositories."""
54 def setUp(self
, commit
=True):
55 TmpPathTestCase
.setUp(self
)
56 self
.initialize_repo()
59 git
.instance().set_worktree(os
.getcwd())
60 gitcfg
.instance().reset()
63 def initialize_repo(self
):
65 git init > /dev/null &&
70 def commit_files(self
):
71 self
.shell('git commit -m"Initial commit" > /dev/null')