diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-15 21:26:20 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-15 21:26:20 +0200 |
commit | e14b468cdd14b4c19370bee96af50d1d788d4f6e (patch) | |
tree | ec5d0bbf08df764fe4ba14b04eee558d6166169c /_test/test_issues.py | |
parent | aaaebefa965eae325adf1bfd800d91765d89fb8b (diff) | |
download | ruamel.yaml-e14b468cdd14b4c19370bee96af50d1d788d4f6e.tar.gz |
fix issue #221 .__add__() and .sort() no longer available on CommentedSeq0.15.57
CommentedSeq + list used to return a list, it now again does so.
sort never worked correctly, it should now (i.e. move the EOL comments along).
*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/test_issues.py')
-rw-r--r-- | _test/test_issues.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/_test/test_issues.py b/_test/test_issues.py index 19eb577..681dc6d 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -248,23 +248,33 @@ class TestIssues: ''' assert save_and_run(dedent(program_src), tmpdir, optimized=True) == 0 - @pytest.mark.xfail(strict=True) def test_issue_221_add(self): from ruamel.yaml.comments import CommentedSeq + a = CommentedSeq([1, 2, 3]) a + [4, 5] - @pytest.mark.xfail(strict=True) - def test_issue_221_copy(self): + def test_issue_221_sort(self): from ruamel.yaml import YAML + from ruamel.yaml.compat import StringIO + yaml = YAML() inp = dedent("""\ - - d # 4 + - d - a # 1 - c # 3 - e # 5 - b # 2 """) a = yaml.load(dedent(inp)) - print(a) a.sort() + buf = StringIO() + yaml.dump(a, buf) + exp = dedent("""\ + - a # 1 + - b # 2 + - c # 3 + - d + - e # 5 + """) + assert buf.getvalue() == exp |