~ubuntu-branches/debian/jessie/bzr-xmloutput/jessie

« back to all changes in this revision

Viewing changes to tests/test_version_xml.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij, Jelmer Vernooij, Max Bowsher
  • Date: 2011-03-07 05:29:49 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110307052949-qj68inm3y8e3eit0
Tags: 0.8.7-1
[ Jelmer Vernooij ]
* New upstream snapshot.

[ Max Bowsher ]
* Run tests in a UTF-8 locale, because they do not properly support the C
  locale.

[ Jelmer Vernooij ]
* Switch to dh_python2. Closes: #616769
* Switch to debhelper 7, drop cdbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import osutils, trace
23
23
from bzrlib.tests import (
24
24
    probe_unicode_in_user_encoding,
25
 
    TestCase,
26
25
    TestCaseInTempDir,
27
26
    TestSkipped,
28
27
    )
30
29
from bzrlib.xml_serializer import elementtree as elementtree
31
30
fromstring = elementtree.ElementTree.fromstring
32
31
 
33
 
 
34
 
class TestVersionXML(TestCase):
 
32
from bzrlib.plugins.xmloutput import versionxml
 
33
 
 
34
 
 
35
class BaseVersionXMLTestCase(TestCaseInTempDir):
 
36
    """Base versionxml testcase."""
 
37
 
 
38
    def setUp(self):
 
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
 
51
 
 
52
    def tearDown(self):
 
53
        # restore the patched function.
 
54
        versionxml._show_source_tree = self.old_show_source_tree
 
55
        TestCaseInTempDir.tearDown(self)
 
56
 
 
57
 
 
58
class TestVersionXML(BaseVersionXMLTestCase):
35
59
 
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')))
52
75
 
53
76
 
54
 
class TestVersionXMLUnicodeOutput(TestCaseInTempDir):
 
77
class TestVersionXMLUnicodeOutput(BaseVersionXMLTestCase):
55
78
 
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')))
73
96
 
74
97
    def test_command(self):
75
 
        self.permit_source_tree_branch_repo()
76
98
        self._check("xmlversion")
77
99
 
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)