File: test_config_parser.py

package info (click to toggle)
osc 1.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,616 kB
  • sloc: python: 33,563; sh: 1,846; xml: 157; makefile: 36; csh: 14
file content (49 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import configparser
import unittest

from osc.OscConfigParser import OscConfigParser


class TestOscConfigParser(unittest.TestCase):
    def setUp(self):
        self.parser = OscConfigParser()
        self.parser.read_string("""
[general]
apiurl = http://localhost

[http://localhost]
credentials_mgr_class=
user=
pass=
""")

    def test_disabled_interpolation(self):
        # with interpolation on, this would raise
        # ValueError: invalid interpolation syntax in '%' at position 0
        self.parser.set("http://localhost", "pass", "%")

    def test_duplicate_section(self):
        conf = """
[general]

[http://localhost]

[http://localhost]
"""
        parser = OscConfigParser()
        self.assertRaises(configparser.DuplicateSectionError, parser.read_string, conf)

    def test_duplicate_option(self):
        conf = """
[general]

[http://localhost]
user=
user=
"""
        parser = OscConfigParser()
        self.assertRaises(configparser.DuplicateOptionError, parser.read_string, conf)


if __name__ == "__main__":
    unittest.main()