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)
示例#2
0
    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)
示例#3
0
    def test_inline_comments(self):
        manifest = """
[test_felinicity.py]
kittens = true # This test requires kittens
cats = false#but not cats
"""
        # make sure inline comments get stripped out, but comments without a space in front don't
        buf = StringIO()
        buf.write(manifest)
        buf.seek(0)
        result = read_ini(buf)[0][1]
        self.assertEqual(result['kittens'], 'true')
        self.assertEqual(result['cats'], "false#but not cats")
示例#4
0
    def test_inline_comments(self):
        manifest = """
[test_felinicity.py]
kittens = true # This test requires kittens
cats = false#but not cats
"""
        # make sure inline comments get stripped out, but comments without a space in front don't
        buf = StringIO()
        buf.write(manifest)
        buf.seek(0)
        result = read_ini(buf)[0][1]
        self.assertEqual(result['kittens'], 'true')
        self.assertEqual(result['cats'], "false#but not cats")
示例#5
0
 def parse_manifest(self, string):
     buf = StringIO()
     buf.write(string)
     buf.seek(0)
     return read_ini(buf)
示例#6
0
 def get_urls(manifest):
     with open(manifest, 'r'):
         return [line[0] for line in read_ini(manifest)]
示例#7
0
 def parse_manifest(self, string):
     buf = StringIO()
     buf.write(string)
     buf.seek(0)
     return read_ini(buf)
示例#8
0
 def inner(string, **kwargs):
     buf = StringIO()
     buf.write(dedent(string))
     buf.seek(0)
     return read_ini(buf, **kwargs)[0]
示例#9
0
 def get_urls(manifest):
     with open(manifest, 'r'):
         return [line[0] for line in read_ini(manifest)]