summaryrefslogtreecommitdiff
path: root/_test/test_version.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-02-18 17:50:19 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-02-18 17:50:19 +0100
commitb8845506796879b1a756471a977ef60eb53f444e (patch)
tree7e6dcc6dc5939dfd78603a1590179d081dc50a63 /_test/test_version.py
parentd588fa199a087020d1c1346d54f24b0972f1fbed (diff)
downloadruamel.yaml-b8845506796879b1a756471a977ef60eb53f444e.tar.gz
- introducing version support and differentiation for RoundTripLoader0.11.0
1.2 no longer interprets sexagesimals, octals wihtout 0o, Yes/No/On/Off by default - added round_trip_load/round_trip_load_all
Diffstat (limited to '_test/test_version.py')
-rw-r--r--_test/test_version.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/_test/test_version.py b/_test/test_version.py
new file mode 100644
index 0000000..55d80c3
--- /dev/null
+++ b/_test/test_version.py
@@ -0,0 +1,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
+