~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Jelmer Vernooij
  • Date: 2016-04-03 16:32:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6617.
  • Revision ID: jelmer@jelmer.uk-20160403163231-h72bo0uyek2gikw0
Don't put French text in doc/en/user-reference when LANGUAGE=fr_CH.UTF_8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
414
414
        self.assertEqual('tree-root-321', inv2['nested-id'].parent_id)
415
415
        self.assertEqual('rev-outer', inv2['nested-id'].revision)
416
416
        self.assertEqual('rev-inner', inv2['nested-id'].reference_revision)
417
 
        self.assertRaises(errors.UnsupportedInventoryKind,
418
 
                          s_v6.read_inventory_from_string,
419
 
                          txt.replace('format="7"', 'format="6"'))
420
 
        self.assertRaises(errors.UnsupportedInventoryKind,
421
 
                          s_v5.read_inventory_from_string,
422
 
                          txt.replace('format="7"', 'format="5"'))
423
417
 
424
418
    def test_roundtrip_inventory_v8(self):
425
419
        inv = self.get_sample_inventory()
506
500
    """Whitebox testing of the _encode_and_escape function."""
507
501
 
508
502
    def setUp(self):
509
 
        TestCase.setUp(self)
 
503
        super(TestEncodeAndEscape, self).setUp()
510
504
        # 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)
 
505
        bzrlib.xml_serializer._clear_cache()
 
506
        self.addCleanup(bzrlib.xml_serializer._clear_cache)
514
507
 
515
508
    def test_simple_ascii(self):
516
509
        # _encode_and_escape always appends a final ", because these parameters
517
510
        # are being used in xml attributes, and by returning it now, we have to
518
511
        # do fewer string operations later.
519
 
        val = bzrlib.xml8._encode_and_escape('foo bar')
 
512
        val = bzrlib.xml_serializer.encode_and_escape('foo bar')
520
513
        self.assertEqual('foo bar"', val)
521
514
        # The second time should be cached
522
 
        val2 = bzrlib.xml8._encode_and_escape('foo bar')
 
515
        val2 = bzrlib.xml_serializer.encode_and_escape('foo bar')
523
516
        self.assertIs(val2, val)
524
517
 
525
518
    def test_ascii_with_xml(self):
526
519
        self.assertEqual('&'"<>"',
527
 
                         bzrlib.xml8._encode_and_escape('&\'"<>'))
 
520
                         bzrlib.xml_serializer.encode_and_escape('&\'"<>'))
528
521
 
529
522
    def test_utf8_with_xml(self):
530
523
        # u'\xb5\xe5&\u062c'
531
524
        utf8_str = '\xc2\xb5\xc3\xa5&\xd8\xac'
532
525
        self.assertEqual('&#181;&#229;&amp;&#1580;"',
533
 
                         bzrlib.xml8._encode_and_escape(utf8_str))
 
526
                         bzrlib.xml_serializer.encode_and_escape(utf8_str))
534
527
 
535
528
    def test_unicode(self):
536
529
        uni_str = u'\xb5\xe5&\u062c'
537
530
        self.assertEqual('&#181;&#229;&amp;&#1580;"',
538
 
                         bzrlib.xml8._encode_and_escape(uni_str))
 
531
                         bzrlib.xml_serializer.encode_and_escape(uni_str))
539
532
 
540
533
 
541
534
class TestMisc(TestCase):