7 from cola
import gitcmd
8 from cola
import gitcfg
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
)
24 parentdir
= os
.path
.dirname(newdir
)
25 if not os
.path
.isdir(parentdir
):
27 if not os
.path
.isdir(newdir
):
31 def test_path(*paths
):
32 cur_tmpdir
= os
.path
.join(tmp_path(), os
.path
.basename(sys
.argv
[0]))
33 root
= '%s-%d.%04d' % (cur_tmpdir
, os
.getpid(), CUR_TEST
)
34 return os
.path
.join(root
, *paths
)
47 """Remove the test's tmp directory and return to the tmp root."""
50 if os
.path
.isdir(path
):
62 out
= core
.read_nointr(p
).strip()
67 class TmpPathTestCase(unittest
.TestCase
):
76 self
.failIf(result
!= 0)
78 def test_path(self
, *paths
):
79 return test_path(*paths
)
82 class GitRepositoryTestCase(TmpPathTestCase
):
83 """Tests that operate on temporary git repositories."""
84 def setUp(self
, commit
=True):
85 TmpPathTestCase
.setUp(self
)
86 self
.initialize_repo()
89 gitcmd
.instance().load_worktree(os
.getcwd())
90 gitcfg
.instance().reset()
92 def initialize_repo(self
):
99 def commit_files(self
):
100 self
.shell('git commit -m"Initial commit" > /dev/null')