From 3d039055e72a8f3185089a2b9f1f162c6f453a77 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Thu, 4 Apr 2019 08:34:46 +0200 Subject: fix update CommentedMap with list of tuples fixes issue #282 *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))* --- _test/test_issues.py | 10 ++++++++++ _test/test_z_data.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/test_issues.py b/_test/test_issues.py index 0d1a43d..5007f60 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -603,6 +603,16 @@ class TestIssues: with pytest.raises(RepresenterError, match='cannot represent'): yaml.dump({'t': t}, stdout) + def test_issue_282(self): + # update from list of tuples caused AttributeError + import ruamel.yaml + yaml_data = ruamel.yaml.comments.CommentedMap([('a', 'apple'), ('b', 'banana')]) + yaml_data.update([('c', 'cantaloupe')]) + yaml_data.update({'d': 'date', 'k': 'kiwi'}) + assert 'c' in yaml_data.keys() + assert 'c' in yaml_data._ok + + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ diff --git a/_test/test_z_data.py b/_test/test_z_data.py index f4e47cf..fcd09be 100644 --- a/_test/test_z_data.py +++ b/_test/test_z_data.py @@ -186,7 +186,7 @@ class TestYAMLData(object): data = doc else: print('no handler for type:', type(doc), repr(doc)) - assert False + raise AssertionError() if typ is None: if data is not None and output is not None: typ = 'rt' @@ -207,7 +207,7 @@ class TestYAMLData(object): self.load_assert(data, confirm, yaml_version=yaml_version) else: print('\nrun type unknown:', typ) - assert False + raise AssertionError() def check_python_version(match, current=None): -- cgit v1.2.1