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