Test_10   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 2
Metric Value
dl 0
loc 15
rs 10
c 3
b 1
f 2
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_42_loads_invalid_input() 0 3 1
A test_44_loads_with_ac_parse_value_option() 0 7 1
1
#
2
# Copyright (C) 2012 - 2017 Satoru SATOH <ssato @ redhat.com>
3
# License: MIT
4
#
5
# pylint: disable=missing-docstring,invalid-name,too-few-public-methods
6
from __future__ import absolute_import
7
8
import anyconfig.backend.ini as TT
9
import tests.backend.common as TBC
10
11
12
# :seealso: `tests.backend.common.CNF_0`
13
CNF_0_S = """\
14
[DEFAULT]
15
a: 0
16
b: bbb
17
c: 5
18
19
[sect0]
20
d: x,y,z
21
"""
22
23
24
class HasParserTrait(TBC.HasParserTrait):
25
26
    psr = TT.Parser()
27
    cnf_s = CNF_0_S
28
29
30
class Test_10(TBC.Test_10_dumps_and_loads, HasParserTrait):
31
32
    load_options = dict(allow_no_value=False, defaults=None)
33
34
    def test_42_loads_invalid_input(self):
35
        invalid_cnf_s = "key=name"  # No section.
36
        self.assertRaises(Exception, self.psr.loads, invalid_cnf_s)
37
38
    def test_44_loads_with_ac_parse_value_option(self):
39
        cnf = self.psr.loads(self.cnf_s, ac_parse_value=True)
40
        ref = self.psr.loads(self.cnf_s)
41
        ref["DEFAULT"]["a"] = ref["sect0"]["a"] = 0
42
        ref["DEFAULT"]["c"] = ref["sect0"]["c"] = 5
43
        ref["sect0"]["d"] = ref["sect0"]["d"].split(',')
44
        self._assert_dicts_equal(cnf, ref=ref)
45
46
47
class Test_20(TBC.Test_20_dump_and_load, HasParserTrait):
48
49
    pass
50
51
# vim:sw=4:ts=4:et:
52