summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-02-27 22:23:14 +0100
committerAnthon van der Neut <anthon@mnt.org>2019-02-27 22:23:14 +0100
commit17af0e7a084955b5c0bf4124bba87190ac16734d (patch)
tree99a390343fd3cc141278c5768e9cbfd15778ebba /_test
parent1fa26ba7438db4edcd6f7748dd7cf2ec3a00c241 (diff)
downloadruamel.yaml-17af0e7a084955b5c0bf4124bba87190ac16734d.tar.gz
fix issue #280 namedtuple erorring in error generation on safe_dump
*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_issues.py14
-rw-r--r--_test/test_z_data.py4
2 files changed, 16 insertions, 2 deletions
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 721f3fe..d5913f6 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -560,8 +560,22 @@ class TestIssues:
"""
d = round_trip(inp) # NOQA
+ def test_issue_280(self):
+ from ruamel.yaml import YAML
+ from ruamel.yaml.representer import RepresenterError
+ from collections import namedtuple
+ from sys import stdout
+ T = namedtuple('T', ('a', 'b'))
+ t = T(1, 2)
+ yaml = YAML()
+ with pytest.raises(RepresenterError, match='cannot represent'):
+ yaml.dump({'t': t}, stdout)
+
# @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError)
# def test_issue_ xxx(self):
# inp = """
# """
# d = round_trip(inp) # NOQA
+
+
+
diff --git a/_test/test_z_data.py b/_test/test_z_data.py
index 99810aa..f4e47cf 100644
--- a/_test/test_z_data.py
+++ b/_test/test_z_data.py
@@ -170,7 +170,7 @@ class TestYAMLData(object):
yaml_version = d.get('yaml_version')
if 'python' in d:
if not check_python_version(d['python']):
- pytest.skip("unsupported version")
+ pytest.skip('unsupported version')
idx += 1
data = output = confirm = python = None
for doc in docs[idx:]:
@@ -230,7 +230,7 @@ def check_python_version(match, current=None):
# assert m[0].isdigit()
# assert m[-1].isdigit()
m = [int(x) for x in m.split('.')]
- current_len = current[:len(m)]
+ current_len = current[: len(m)]
# print(m, current, current_len)
if minimal:
if current_len >= m: