|
1
|
|
|
# |
|
2
|
|
|
# Copyright (C) 2012 - 2018 Satoru SATOH <ssato @ redhat.com> |
|
3
|
|
|
# Copyright (C) 2017 Red Hat, Inc. |
|
4
|
|
|
# License: MIT |
|
5
|
|
|
# |
|
6
|
|
|
# pylint: disable=missing-docstring,invalid-name,too-few-public-methods |
|
7
|
|
|
# pylint: disable=ungrouped-imports |
|
8
|
|
|
from __future__ import absolute_import |
|
9
|
|
|
|
|
10
|
|
|
import os |
|
11
|
|
|
import anyconfig.backend.yaml as TT |
|
12
|
|
|
import tests.backend.common as TBC |
|
13
|
|
|
|
|
14
|
|
|
from anyconfig.compat import OrderedDict |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
CNF_S = """ |
|
18
|
|
|
a: 0 |
|
19
|
|
|
b: bbb |
|
20
|
|
|
c: |
|
21
|
|
|
- 1 |
|
22
|
|
|
- 2 |
|
23
|
|
|
- 3 |
|
24
|
|
|
|
|
25
|
|
|
sect0: §0 |
|
26
|
|
|
d: ["x", "y", "z"] |
|
27
|
|
|
sect1: |
|
28
|
|
|
<<: *sect0 |
|
29
|
|
|
e: true |
|
30
|
|
|
""" |
|
31
|
|
|
|
|
32
|
|
|
CNF = OrderedDict((("a", 0), ("b", "bbb"), ("c", [1, 2, 3]), |
|
33
|
|
|
("sect0", OrderedDict((("d", "x y z".split()), ))), |
|
34
|
|
|
("sect1", OrderedDict((("d", "x y z".split()), |
|
35
|
|
|
("e", True)))))) |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
class HasParserTrait(TBC.HasParserTrait): |
|
39
|
|
|
|
|
40
|
|
|
psr = TT.Parser() |
|
41
|
|
|
cnf = CNF |
|
42
|
|
|
cnf_s = CNF_S |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
class Test_10(TBC.Test_10_dumps_and_loads, HasParserTrait): |
|
46
|
|
|
|
|
47
|
|
|
load_options = dict(ac_safe=True, Loader=TT.yaml.loader.Loader) |
|
48
|
|
|
dump_options = dict(ac_safe=True) |
|
49
|
|
|
empty_patterns = [('', {}), (' ', {}), ('[]', []), |
|
50
|
|
|
("#%s#%s" % (os.linesep, os.linesep), {})] |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
class Test_20(TBC.Test_20_dump_and_load, HasParserTrait): |
|
54
|
|
|
pass |
|
55
|
|
|
|
|
56
|
|
|
# vim:sw=4:ts=4:et: |
|
57
|
|
|
|