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 /testing/mozbase/manifestparser/tests/test_read_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 'testing/mozbase/manifestparser/tests/test_read_ini.py')
-rwxr-xr-x | testing/mozbase/manifestparser/tests/test_read_ini.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/testing/mozbase/manifestparser/tests/test_read_ini.py b/testing/mozbase/manifestparser/tests/test_read_ini.py new file mode 100755 index 000000000..df4a8973b --- /dev/null +++ b/testing/mozbase/manifestparser/tests/test_read_ini.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +""" +test .ini parsing + +ensure our .ini parser is doing what we want; to be deprecated for +python's standard ConfigParser when 2.7 is reality so OrderedDict +is the default: + +http://docs.python.org/2/library/configparser.html +""" + +import unittest +from manifestparser import read_ini +from ConfigParser import ConfigParser +from StringIO import StringIO + + +class IniParserTest(unittest.TestCase): + + def test_inline_comments(self): + """ + We have no inline comments; so we're testing to ensure we don't: + https://bugzilla.mozilla.org/show_bug.cgi?id=855288 + """ + + # test '#' inline comments (really, the lack thereof) + string = """[test_felinicity.py] +kittens = true # This test requires kittens +""" + buffer = StringIO() + buffer.write(string) + buffer.seek(0) + result = read_ini(buffer)[0][1]['kittens'] + self.assertEqual(result, "true # This test requires kittens") + + # compare this to ConfigParser + # python 2.7 ConfigParser does not support '#' as an + # inline comment delimeter (for "backwards compatability"): + # http://docs.python.org/2/library/configparser.html + buffer.seek(0) + parser = ConfigParser() + parser.readfp(buffer) + control = parser.get('test_felinicity.py', 'kittens') + self.assertEqual(result, control) + + # test ';' inline comments (really, the lack thereof) + string = string.replace('#', ';') + buffer = StringIO() + buffer.write(string) + buffer.seek(0) + result = read_ini(buffer)[0][1]['kittens'] + self.assertEqual(result, "true ; This test requires kittens") + + # compare this to ConfigParser + # python 2.7 ConfigParser *does* support ';' as an + # inline comment delimeter (ibid). + # Python 3.x configparser, OTOH, does not support + # inline-comments by default. It does support their specification, + # though they are weakly discouraged: + # http://docs.python.org/dev/library/configparser.html + buffer.seek(0) + parser = ConfigParser() + parser.readfp(buffer) + control = parser.get('test_felinicity.py', 'kittens') + self.assertNotEqual(result, control) + + +if __name__ == '__main__': + unittest.main() |