~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
508
508
    def setUp(self):
509
509
        TestCase.setUp(self)
510
510
        # Keep the cache clear before and after the test
511
 
        bzrlib.xml8._ensure_utf8_re()
512
 
        bzrlib.xml8._clear_cache()
513
 
        self.addCleanup(bzrlib.xml8._clear_cache)
 
511
        bzrlib.xml_serializer._clear_cache()
 
512
        self.addCleanup(bzrlib.xml_serializer._clear_cache)
514
513
 
515
514
    def test_simple_ascii(self):
516
515
        # _encode_and_escape always appends a final ", because these parameters
517
516
        # are being used in xml attributes, and by returning it now, we have to
518
517
        # do fewer string operations later.
519
 
        val = bzrlib.xml8._encode_and_escape('foo bar')
 
518
        val = bzrlib.xml_serializer.encode_and_escape('foo bar')
520
519
        self.assertEqual('foo bar"', val)
521
520
        # The second time should be cached
522
 
        val2 = bzrlib.xml8._encode_and_escape('foo bar')
 
521
        val2 = bzrlib.xml_serializer.encode_and_escape('foo bar')
523
522
        self.assertIs(val2, val)
524
523
 
525
524
    def test_ascii_with_xml(self):
526
525
        self.assertEqual('&'"<>"',
527
 
                         bzrlib.xml8._encode_and_escape('&\'"<>'))
 
526
                         bzrlib.xml_serializer.encode_and_escape('&\'"<>'))
528
527
 
529
528
    def test_utf8_with_xml(self):
530
529
        # u'\xb5\xe5&\u062c'
531
530
        utf8_str = '\xc2\xb5\xc3\xa5&\xd8\xac'
532
531
        self.assertEqual('&#181;&#229;&amp;&#1580;"',
533
 
                         bzrlib.xml8._encode_and_escape(utf8_str))
 
532
                         bzrlib.xml_serializer.encode_and_escape(utf8_str))
534
533
 
535
534
    def test_unicode(self):
536
535
        uni_str = u'\xb5\xe5&\u062c'
537
536
        self.assertEqual('&#181;&#229;&amp;&#1580;"',
538
 
                         bzrlib.xml8._encode_and_escape(uni_str))
 
537
                         bzrlib.xml_serializer.encode_and_escape(uni_str))
539
538
 
540
539
 
541
540
class TestMisc(TestCase):