17
17
"""Test the GitDir class"""
21
from bzrlib import bzrdir
23
from bzrlib.plugins.git import tests
24
from bzrlib.plugins.git.gitlib import git_dir
19
from bzrlib import bzrdir, errors
21
from bzrlib.plugins.git import dir, tests, workingtree
27
24
class TestGitDir(tests.TestCaseInTempDir):
29
26
_test_needs_features = [tests.GitCommandFeature]
31
28
def test_open_existing(self):
32
p = subprocess.Popen(['git', 'init'],
33
stdout=subprocess.PIPE,
34
stderr=subprocess.PIPE)
37
gd = bzrdir.BzrDir.open('.')
38
self.assertIsInstance(gd, git_dir.GitDir)
31
gd = bzrdir.BzrDir.open('.')
32
self.assertIsInstance(gd, dir.GitDir)
34
def test_open_workingtree(self):
37
gd = bzrdir.BzrDir.open('.')
38
wt = gd.open_workingtree()
39
self.assertIsInstance(wt, workingtree.GitWorkingTree)
41
def test_open_workingtree_bare(self):
42
tests.run_git('--bare', 'init')
44
gd = bzrdir.BzrDir.open('.')
45
self.assertRaises(errors.NoWorkingTree, gd.open_workingtree)
48
class TestGitDirFormat(tests.TestCaseInTempDir):
50
_test_needs_features = [tests.GitCommandFeature]
53
super(TestGitDirFormat, self).setUp()
54
self.format = dir.GitBzrDirFormat()
56
def test_get_format_description(self):
57
self.assertEquals("Local Git Repository",
58
self.format.get_format_description())