From afdc275f756c47d2aab65c030a9ccce749b108e6 Mon Sep 17 00:00:00 2001 From: Axel Hecht Date: Sat, 9 Jan 2016 17:13:13 +0100 Subject: [PATCH] Bug 1237678 - update compare-locales to version 1.0. r=mathjazz changeset: 300933:aa4e0275bb3c tag: tip user: Axel Hecht summary: bug 1237678, update compare-locales to version 1.0, r=mathjazz --- .../compare_locales/__init__.py | 2 +- .../compare-locales/compare_locales/checks.py | 28 +++++++-- .../compare_locales/compare.py | 10 +-- .../compare_locales/tests/test_checks.py | 62 ++++++++++++++++++- 4 files changed, 89 insertions(+), 13 deletions(-) diff --git a/python/compare-locales/compare_locales/__init__.py b/python/compare-locales/compare_locales/__init__.py index ca1d7fe37e6f..346c93fc5729 100644 --- a/python/compare-locales/compare_locales/__init__.py +++ b/python/compare-locales/compare_locales/__init__.py @@ -1 +1 @@ -version = "0.10.1a" +version = "1.0" diff --git a/python/compare-locales/compare_locales/checks.py b/python/compare-locales/compare_locales/checks.py index a359a88ae587..ee3bef03ddf6 100644 --- a/python/compare-locales/compare_locales/checks.py +++ b/python/compare-locales/compare_locales/checks.py @@ -240,6 +240,7 @@ class DTDChecker(Checker): # find entities the refValue references, # reusing markup from DTDParser. reflist = self.known_entities(refValue) + inContext = self.entities_for_value(refValue) entities = ''.join('' % s for s in sorted(reflist)) parser = sax.make_parser() parser.setFeature(sax.handler.feature_external_ges, False) @@ -262,9 +263,6 @@ class DTDChecker(Checker): l10nlist = self.entities_for_value(l10nValue) missing = sorted(l10nlist - reflist) _entities = entities + ''.join('' % s for s in missing) - warntmpl = u'Referencing unknown entity `%s`' - if reflist: - warntmpl += ' (%s known)' % ', '.join(sorted(reflist)) if self.processContent is not None: self.texthandler.textcontent = '' parser.setContentHandler(self.texthandler) @@ -295,9 +293,29 @@ class DTDChecker(Checker): col -= len(" self._test('''''', tuple()) +class TestEntitiesInDTDs(BaseHelper): + file = File('foo.dtd', 'foo.dtd') + refContent = ''' + + + +''' + + def testOK(self): + self._test('''''', tuple(), + with_ref_file=True) + + def testMismatch(self): + self._test('''''', + (('warning', (0, 0), + 'Entity brandShortName referenced, ' + 'but brandShorterName used in context', + 'xmlparse'),), + with_ref_file=True) + + def testAcross(self): + self._test('''''', + tuple(), + with_ref_file=True) + + def testAcrossWithMismatch(self): + '''If we could tell that ent.start and ent.end are one string, + we should warn. Sadly, we can't, so this goes without warning.''' + self._test('''''', + tuple(), + with_ref_file=True) + + def testUnknownWithRef(self): + self._test('''''', + (('warning', + (0, 0), + 'Referencing unknown entity `foopy` ' + '(brandShorterName used in context, ' + 'brandShortName known)', + 'xmlparse'),), + with_ref_file=True) + + def testUnknown(self): + self._test('''''', + (('warning', + (0, 0), + 'Referencing unknown entity `foopy`' + ' (brandShortName, brandShorterName known)', + 'xmlparse'),), + with_ref_file=True) + + class TestAndroid(unittest.TestCase): """Test Android checker