Completed
Push — master ( bff2ab...5dc771 )
by Satoru
01:07
created

Test00.test_20_escape()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 4
rs 10
1
#
2
# Copyright (C) 2012 - 2015 Satoru SATOH <ssato @ redhat.com>
3
# License: MIT
4
#
5
# pylint: disable=missing-docstring
6
from __future__ import absolute_import
7
import unittest
8
import anyconfig.backend.properties as TT
9
import anyconfig.backend.tests.ini
10
11
from anyconfig.compat import OrderedDict as ODict
12
13
14
CNF_S = """
15
a = 0
16
b = bbb
17
18
sect0.c = x;y;z
19
sect1.d = \\
20
    1,2,3
21
"""
22
CNF = ODict((("a", "0"), ("b", "bbb"),
23
             ("sect0.c", "x;y;z"), ("sect1.d", "1,2,3")))
24
25
26
class Test00(unittest.TestCase):
27
28
    def test_10_unescape(self):
29
        exp = "aaa:bbb"
30
        res = TT.unescape(r"aaa\:bbb")
31
        self.assertEqual(res, exp, res)
32
33
    def test_12_unescape(self):
34
        exp = r"\a"
35
        res = TT.unescape(r"\\a")
36
        self.assertEqual(res, exp, res)
37
38
    def test_20_escape(self):
39
        exp = r"\:\=\\ "
40
        res = TT.escape(r":=\ ")
41
        self.assertEqual(res, exp, res)
42
43
44
class Test10(anyconfig.backend.tests.ini.Test10):
45
46
    cnf = CNF
47
    cnf_s = CNF_S
48
    load_options = dict(comment_markers=("//", "#", "!"))
49
    dump_options = dict(dummy_opt="this_will_be_ignored")
50
51
    def setUp(self):
52
        self.psr = TT.Parser()
53
54
55
class Test20(anyconfig.backend.tests.ini.Test20):
56
57
    psr_cls = TT.Parser
58
    cnf = CNF
59
    cnf_s = CNF_S
60
    cnf_fn = "conf.properties"
61
62
# vim:sw=4:ts=4:et:
63