513
513
# Keep the cache clear before and after the test
514
bzrlib.xml5._ensure_utf8_re()
515
bzrlib.xml5._clear_cache()
516
self.addCleanup(bzrlib.xml5._clear_cache)
514
bzrlib.xml8._ensure_utf8_re()
515
bzrlib.xml8._clear_cache()
516
self.addCleanup(bzrlib.xml8._clear_cache)
518
518
def test_simple_ascii(self):
519
519
# _encode_and_escape always appends a final ", because these parameters
520
520
# are being used in xml attributes, and by returning it now, we have to
521
521
# do fewer string operations later.
522
val = bzrlib.xml5._encode_and_escape('foo bar')
522
val = bzrlib.xml8._encode_and_escape('foo bar')
523
523
self.assertEqual('foo bar"', val)
524
524
# The second time should be cached
525
val2 = bzrlib.xml5._encode_and_escape('foo bar')
525
val2 = bzrlib.xml8._encode_and_escape('foo bar')
526
526
self.assertIs(val2, val)
528
528
def test_ascii_with_xml(self):
529
529
self.assertEqual('&'"<>"',
530
bzrlib.xml5._encode_and_escape('&\'"<>'))
530
bzrlib.xml8._encode_and_escape('&\'"<>'))
532
532
def test_utf8_with_xml(self):
533
533
# u'\xb5\xe5&\u062c'
534
534
utf8_str = '\xc2\xb5\xc3\xa5&\xd8\xac'
535
535
self.assertEqual('µå&ج"',
536
bzrlib.xml5._encode_and_escape(utf8_str))
536
bzrlib.xml8._encode_and_escape(utf8_str))
538
538
def test_unicode(self):
539
539
uni_str = u'\xb5\xe5&\u062c'
540
540
self.assertEqual('µå&ج"',
541
bzrlib.xml5._encode_and_escape(uni_str))
541
bzrlib.xml8._encode_and_escape(uni_str))