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"'))
418
424
def test_roundtrip_inventory_v8(self):
419
425
inv = self.get_sample_inventory()
503
509
TestCase.setUp(self)
504
510
# Keep the cache clear before and after the test
505
bzrlib.xml_serializer._clear_cache()
506
self.addCleanup(bzrlib.xml_serializer._clear_cache)
511
bzrlib.xml8._ensure_utf8_re()
512
bzrlib.xml8._clear_cache()
513
self.addCleanup(bzrlib.xml8._clear_cache)
508
515
def test_simple_ascii(self):
509
516
# _encode_and_escape always appends a final ", because these parameters
510
517
# are being used in xml attributes, and by returning it now, we have to
511
518
# do fewer string operations later.
512
val = bzrlib.xml_serializer.encode_and_escape('foo bar')
519
val = bzrlib.xml8._encode_and_escape('foo bar')
513
520
self.assertEqual('foo bar"', val)
514
521
# The second time should be cached
515
val2 = bzrlib.xml_serializer.encode_and_escape('foo bar')
522
val2 = bzrlib.xml8._encode_and_escape('foo bar')
516
523
self.assertIs(val2, val)
518
525
def test_ascii_with_xml(self):
519
526
self.assertEqual('&'"<>"',
520
bzrlib.xml_serializer.encode_and_escape('&\'"<>'))
527
bzrlib.xml8._encode_and_escape('&\'"<>'))
522
529
def test_utf8_with_xml(self):
523
530
# u'\xb5\xe5&\u062c'
524
531
utf8_str = '\xc2\xb5\xc3\xa5&\xd8\xac'
525
532
self.assertEqual('µå&ج"',
526
bzrlib.xml_serializer.encode_and_escape(utf8_str))
533
bzrlib.xml8._encode_and_escape(utf8_str))
528
535
def test_unicode(self):
529
536
uni_str = u'\xb5\xe5&\u062c'
530
537
self.assertEqual('µå&ج"',
531
bzrlib.xml_serializer.encode_and_escape(uni_str))
538
bzrlib.xml8._encode_and_escape(uni_str))
534
541
class TestMisc(TestCase):