diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /python/compare-locales/compare_locales/tests/test_ini.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'python/compare-locales/compare_locales/tests/test_ini.py')
-rw-r--r-- | python/compare-locales/compare_locales/tests/test_ini.py | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/python/compare-locales/compare_locales/tests/test_ini.py b/python/compare-locales/compare_locales/tests/test_ini.py new file mode 100644 index 000000000..4c8cc03e1 --- /dev/null +++ b/python/compare-locales/compare_locales/tests/test_ini.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import unittest + +from compare_locales.tests import ParserTestMixin + + +mpl2 = '''\ +; This Source Code Form is subject to the terms of the Mozilla Public +; License, v. 2.0. If a copy of the MPL was not distributed with this file, +; You can obtain one at http://mozilla.org/MPL/2.0/. +''' + + +class TestIniParser(ParserTestMixin, unittest.TestCase): + + filename = 'foo.ini' + + def testSimpleHeader(self): + self._test('''; This file is in the UTF-8 encoding +[Strings] +TitleText=Some Title +''', (('TitleText', 'Some Title'),)) + self.assert_('UTF-8' in self.parser.header) + + def testMPL2_Space_UTF(self): + self._test(mpl2 + ''' +; This file is in the UTF-8 encoding +[Strings] +TitleText=Some Title +''', (('TitleText', 'Some Title'),)) + self.assert_('MPL' in self.parser.header) + + def testMPL2_Space(self): + self._test(mpl2 + ''' +[Strings] +TitleText=Some Title +''', (('TitleText', 'Some Title'),)) + self.assert_('MPL' in self.parser.header) + + def testMPL2_MultiSpace(self): + self._test(mpl2 + '''\ + +; more comments + +[Strings] +TitleText=Some Title +''', (('TitleText', 'Some Title'),)) + self.assert_('MPL' in self.parser.header) + + def testMPL2_JunkBeforeCategory(self): + self._test(mpl2 + '''\ +Junk +[Strings] +TitleText=Some Title +''', (('_junk_\\d+_0-213$', mpl2 + '''\ +Junk +[Strings]'''), ('TitleText', 'Some Title'))) + self.assert_('MPL' not in self.parser.header) + + def test_TrailingComment(self): + self._test(mpl2 + ''' +[Strings] +TitleText=Some Title +;Stray trailing comment +''', (('TitleText', 'Some Title'),)) + self.assert_('MPL' in self.parser.header) + + def test_SpacedTrailingComments(self): + self._test(mpl2 + ''' +[Strings] +TitleText=Some Title + +;Stray trailing comment +;Second stray comment + +''', (('TitleText', 'Some Title'),)) + self.assert_('MPL' in self.parser.header) + + def test_TrailingCommentsAndJunk(self): + self._test(mpl2 + ''' +[Strings] +TitleText=Some Title + +;Stray trailing comment +Junk +;Second stray comment + +''', (('TitleText', 'Some Title'), ('_junk_\\d+_231-284$', '''\ + +;Stray trailing comment +Junk +;Second stray comment + +'''))) + self.assert_('MPL' in self.parser.header) + + def test_JunkInbetweenEntries(self): + self._test(mpl2 + ''' +[Strings] +TitleText=Some Title + +Junk + +Good=other string +''', (('TitleText', 'Some Title'), ('_junk_\\d+_231-236$', '''\ + +Junk'''), ('Good', 'other string'))) + self.assert_('MPL' in self.parser.header) + +if __name__ == '__main__': + unittest.main() |