summaryrefslogtreecommitdiff
path: root/_test/test_version.py
blob: 55d80c33fdcad48144908f3e2c322c5b17080b6a (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# coding: utf-8

import pytest                        # NOQA

import ruamel.yaml
from roundtrip import dedent

def load(s, version=None):
    return ruamel.yaml.round_trip_load(dedent(s), version)



class TestVersions:
    def test_explicit_1_2(self):
        l = load("""\
        %YAML 1.2
        ---
        - 12:34:56
        - 012
        - 012345678
        - 0o12
        - on
        - off
        - yes
        - no
        - true
        """)
        assert l[0] == '12:34:56'
        assert l[1] == 12
        assert l[2] ==  '012345678'
        assert l[3] == 10
        assert l[4] == 'on'
        assert l[5] == 'off'
        assert l[6] == 'yes'
        assert l[7] == 'no'
        assert l[8] is True

    def test_explicit_1_1(self):
        l = load("""\
        %YAML 1.1
        ---
        - 12:34:56
        - 012
        - 012345678
        - 0o12
        - on
        - off
        - yes
        - no
        - true
        """)
        assert l[0] == 45296
        assert l[1] == 10
        assert l[2] ==  '012345678'
        assert l[3] == 10
        assert l[4] is True
        assert l[5] is False
        assert l[6] is True
        assert l[7] is False
        assert l[8] is True

    def test_implicit_1_2(self):
        l = load("""\
        - 12:34:56
        - 012
        - 012345678
        - 0o12
        - on
        - off
        - yes
        - no
        - true
        """)
        assert l[0] == '12:34:56'
        assert l[1] == 12
        assert l[2] ==  '012345678'
        assert l[3] == 10
        assert l[4] == 'on'
        assert l[5] == 'off'
        assert l[6] == 'yes'
        assert l[7] == 'no'
        assert l[8] is True

    def test_load_version_1_1(self):
        l = load("""\
        - 12:34:56
        - 012
        - 012345678
        - 0o12
        - on
        - off
        - yes
        - no
        - true
        """, version="1.1")
        assert l[0] == 45296
        assert l[1] == 10
        assert l[2] ==  '012345678'
        assert l[3] == 10
        assert l[4] is True
        assert l[5] is False
        assert l[6] is True
        assert l[7] is False
        assert l[8] is True