30
29
from bzrlib.xml_serializer import elementtree as elementtree
31
30
fromstring = elementtree.ElementTree.fromstring
34
class TestVersionXML(TestCase):
32
from bzrlib.plugins.xmloutput import versionxml
35
class BaseVersionXMLTestCase(TestCaseInTempDir):
36
"""Base versionxml testcase."""
39
TestCaseInTempDir.setUp(self)
40
# versionxml tries to call bzrlib.version._get_bzr_source_tree(), which
41
# tries an open_containing within the bzr installation. This will cause
42
# a test isolation failure. You might hope that you could avoid this
43
# with TestCase.permit_source_tree_branch_repo(), but this does not
44
# work when running against a bzr installation that has no source tree,
45
# as in this case, the open_containing operation needs to recurse
46
# upwards to the filesystem root before it knows that it is finished.
47
# Therefore we just stub out the relevant function so that it does not
48
# call the problem method.
49
self.old_show_source_tree = versionxml._show_source_tree
50
versionxml._show_source_tree = lambda _: None
53
# restore the patched function.
54
versionxml._show_source_tree = self.old_show_source_tree
55
TestCaseInTempDir.tearDown(self)
58
class TestVersionXML(BaseVersionXMLTestCase):
36
60
def test_version(self):
37
self.permit_source_tree_branch_repo()
38
61
out = self.run_bzr("xmlversion")[0]
39
62
versionElem = fromstring(out)
40
63
self.assertTrue(len(out) > 0)
51
74
self.assertEquals(1, len(versionElem.findall('python/standard_library')))
54
class TestVersionXMLUnicodeOutput(TestCaseInTempDir):
77
class TestVersionXMLUnicodeOutput(BaseVersionXMLTestCase):
56
79
def _check(self, args):
57
80
# Even though trace._bzr_log_filename variable
72
95
self.assertEquals(1, len(versionElem.findall('bazaar/log_file')))
74
97
def test_command(self):
75
self.permit_source_tree_branch_repo()
76
98
self._check("xmlversion")
78
100
def test_unicode_bzr_home(self):
82
104
' encoding %s' % \
83
105
bzrlib.osutils.get_user_encoding())
84
106
osutils.set_or_unset_env('BZR_HOME', str_val)
85
self.permit_source_tree_branch_repo()
86
107
out = self.run_bzr("xmlversion")[0]
87
108
self.assertTrue(len(out) > 0)
88
109
versionElem = fromstring(out)