From 097ba3e526e63b94f0bba4ed9556eb602a9c63dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Tue, 4 Apr 2023 18:19:11 +0200 Subject: [PATCH] anchors: Fix invalid YAML in aliases test cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although accepted by PyYAML, `{*x: 4}` is not valid YAML: it should be noted `{*x : 4}`. The reason is that a colon can be part of an anchor name. See this comment from Tina Müller for more details: https://github.com/adrienverge/yamllint/pull/550#discussion_r1155297373 Even if it's not a problem for yamllint, let's fix our tests to include valid YAML snippets. --- tests/rules/test_anchors.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/rules/test_anchors.py b/tests/rules/test_anchors.py index da1c5233..e024b1ae 100644 --- a/tests/rules/test_anchors.py +++ b/tests/rules/test_anchors.py @@ -46,7 +46,7 @@ def test_disabled(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n' '...\n', conf) self.check('---\n' '- &i 42\n' @@ -74,7 +74,7 @@ def test_disabled(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n' '...\n', conf) def test_forbid_undeclared_aliases(self): @@ -106,7 +106,7 @@ def test_forbid_undeclared_aliases(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n' '...\n', conf) self.check('---\n' '- &i 42\n' @@ -134,7 +134,7 @@ def test_forbid_undeclared_aliases(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n' '...\n', conf, problem1=(9, 3), problem2=(10, 3), @@ -173,7 +173,7 @@ def test_forbid_duplicated_anchors(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n' '...\n', conf) self.check('---\n' '- &i 42\n' @@ -201,7 +201,7 @@ def test_forbid_duplicated_anchors(self): ' <<: *b_m\n' ' foo: bar\n' '---\n' - '{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n' + '{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n' '...\n', conf, problem1=(5, 3), problem2=(6, 3),