8 from cola
import gitcfg
9 from cola
import gitcmds
13 """Returns a path relative to the test/tmp directory"""
14 return os
.path
.join(os
.path
.dirname(__file__
), 'tmp', *paths
)
18 return os
.path
.join(os
.path
.dirname(__file__
), 'fixtures', *paths
)
27 out
= core
.fread(p
).strip()
32 class TmpPathTestCase(unittest
.TestCase
):
34 self
._testdir
= tempfile
.mkdtemp('_cola_test')
35 os
.chdir(self
._testdir
)
38 """Remove the test directory and return to the tmp root."""
45 self
.failIf(result
!= 0)
47 def test_path(self
, *paths
):
48 return os
.path
.join(self
._testdir
, *paths
)
51 class GitRepositoryTestCase(TmpPathTestCase
):
52 """Tests that operate on temporary git repositories."""
53 def setUp(self
, commit
=True):
54 TmpPathTestCase
.setUp(self
)
55 self
.initialize_repo()
58 git
.instance().set_worktree(core
.getcwd())
59 gitcfg
.instance().reset()
62 def initialize_repo(self
):
64 git init > /dev/null &&
69 def commit_files(self
):
70 self
.shell('git commit -m"Initial commit" > /dev/null')