From 0e09430734ff9e4be6a783f53954ed77b4f03e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 8 Jul 2022 17:51:10 +0200 Subject: [PATCH] key-duplicates: Fix failing test for missing space after colon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit c268a82 "key-duplicates: Don't crash on redundant closing brackets or braces" fixed a problem but introduced another one: it crashes on systems with (I guess) an old version of PyYAML. This is probably linked to the "Allow colon in a plain scalar in a flow context" issue on PyYAML [1]. For example, this problem happens on CentOS 8: FAIL: test_disabled (tests.rules.test_key_duplicates.KeyDuplicatesTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "…/tests/rules/test_key_duplicates.py", line 90, in test_disabled '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax')) File "…/tests/common.py", line 54, in check self.assertEqual(real_problems, expected_problems) AssertionError: Lists differ: … - [2:3: syntax error: found unexpected ':' (syntax)] + [2:11: ] I propose to simply fix the *space following a colon* problem, since it's not related to what the original author @tamere-allo-peter tried to fix. [1]: https://github.com/yaml/pyyaml/pull/45 --- tests/rules/test_key_duplicates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rules/test_key_duplicates.py b/tests/rules/test_key_duplicates.py index 3be7741e..3f8a9e62 100644 --- a/tests/rules/test_key_duplicates.py +++ b/tests/rules/test_key_duplicates.py @@ -87,7 +87,7 @@ def test_disabled(self): ' <<: *anchor_one\n' ' <<: *anchor_two\n', conf) self.check('---\n' - '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax')) + '{a: 1, b: 2}}\n', conf, problem=(2, 13, 'syntax')) self.check('---\n' '[a, b, c]]\n', conf, problem=(2, 10, 'syntax')) @@ -169,7 +169,7 @@ def test_enabled(self): ' <<: *anchor_one\n' ' <<: *anchor_two\n', conf) self.check('---\n' - '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax')) + '{a: 1, b: 2}}\n', conf, problem=(2, 13, 'syntax')) self.check('---\n' '[a, b, c]]\n', conf, problem=(2, 10, 'syntax'))