summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-11-09 10:47:11 +0100
committerAnthon van der Neut <anthon@mnt.org>2018-11-09 10:47:11 +0100
commit68ea6b9ef755296c169b5416fe46ac48250e3c62 (patch)
tree8a44637378f20053b3c22ed342bdb2d13805dc97 /_test
parent11e092f5746f4437628a4131ea8727db6c4c5692 (diff)
downloadruamel.yaml-68ea6b9ef755296c169b5416fe46ac48250e3c62.tar.gz
fix issue #194 object attributes always sorted0.15.77
Test for this issue in: https://bitbucket.org/ruamel/yaml.data/src/default/object/control_base_representer_mapping_sort.yaml *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to '_test')
-rw-r--r--_test/test_z_data.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/_test/test_z_data.py b/_test/test_z_data.py
index d106a2a..b0464ba 100644
--- a/_test/test_z_data.py
+++ b/_test/test_z_data.py
@@ -2,6 +2,7 @@
from __future__ import print_function, unicode_literals
+import sys
import pytest # NOQA
import warnings # NOQA
@@ -83,7 +84,10 @@ def pytest_generate_tests(metafunc):
paths = sorted(base_path.glob('**/*.yaml'))
idlist = []
for path in paths:
- idlist.append(path.stem)
+ stem = path.stem
+ if stem.startswith('.#'): # skip emacs temporary file
+ continue
+ idlist.append(stem)
test_yaml.append([path])
metafunc.parametrize(['yaml'], test_yaml, ids=idlist, scope='class')
@@ -160,6 +164,9 @@ class TestYAMLData(object):
d = docs[0]
typ = d.get('type')
yaml_version = d.get('yaml_version')
+ if 'python' in d:
+ if not check_python_version(d['python']):
+ pytest.skip("unsupported version")
idx += 1
data = output = confirm = python = None
for doc in docs[idx:]:
@@ -196,3 +203,34 @@ class TestYAMLData(object):
else:
print('\nrun type unknown:', typ)
assert False
+
+
+def check_python_version(match, current=None):
+ """
+ version indication, return True if version matches.
+ match should be something like 3.6+, or [2.7, 3.3] etc. Floats
+ are converted to strings. Single values are made into lists.
+ """
+ if current is None:
+ current = list(sys.version_info[:3])
+ if not isinstance(match, list):
+ match = [match]
+ for m in match:
+ minimal = False
+ if isinstance(m, float):
+ m = str(m)
+ if m.endswith('+'):
+ minimal = True
+ m = m[:-1]
+ # assert m[0].isdigit()
+ # assert m[-1].isdigit()
+ m = [int(x) for x in m.split('.')]
+ current_len = current[:len(m)]
+ # print(m, current, current_len)
+ if minimal:
+ if current_len >= m:
+ return True
+ else:
+ if current_len == m:
+ return True
+ return False