diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-08 17:38:43 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-08 17:38:43 +0200 |
commit | d68c914426b826ff9b076eb870aebdfdef5d82aa (patch) | |
tree | 7f00c92a3e5b6554f82197a79120494b77b5c3b3 /_test | |
parent | 65c335bcf426d4954c079eda2cc5414259bea4f9 (diff) | |
download | ruamel.yaml-d68c914426b826ff9b076eb870aebdfdef5d82aa.tar.gz |
fix issue #124: incorrect tags for class methods
Diffstat (limited to '_test')
-rw-r--r-- | _test/roundtrip.py | 2 | ||||
-rw-r--r-- | _test/test_yamlobject.py | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/_test/roundtrip.py b/_test/roundtrip.py index 86e4862..c9b4ffb 100644 --- a/_test/roundtrip.py +++ b/_test/roundtrip.py @@ -228,7 +228,7 @@ def save_and_run(program, base_dir=None, file_name=None): print('running:', *cmd) check_output(cmd, stderr=STDOUT, universal_newlines=True) except CalledProcessError as exception: - print("##### Running '{} {}' FAILED #####".format(sys.exeutable, file_name)) + print("##### Running '{} {}' FAILED #####".format(sys.executable, file_name)) print(exception.output) return exception.returncode return 0 diff --git a/_test/test_yamlobject.py b/_test/test_yamlobject.py index 1d730b5..2cb7b11 100644 --- a/_test/test_yamlobject.py +++ b/_test/test_yamlobject.py @@ -2,6 +2,7 @@ from __future__ import print_function +import sys import pytest # NOQA from roundtrip import save_and_run # NOQA @@ -42,3 +43,42 @@ def test_monster(tmpdir): """) ''' assert save_and_run(program_src, tmpdir) == 0 + + + +@pytest.mark.skipif(sys.version_info < (3, 0), reason='no __qualname__') +def test_qualified_name00(tmpdir): + """issue 214""" + program_src = u'''\ + from ruamel.yaml import YAML + from ruamel.yaml.compat import StringIO + + class A: + def f(self): + pass + + yaml = YAML(typ='unsafe') + buf = StringIO() + yaml.dump(A.f, buf) + res = buf.getvalue() + assert res == '!!python/name:__main__.A.f \\n...\\n' + x = yaml.load(res) + assert x == A.f + ''' + assert save_and_run(program_src, tmpdir) == 0 + + +@pytest.mark.skipif(sys.version_info < (3, 0), reason='no __qualname__') +def test_qualified_name01(tmpdir): + """issue 214""" + from ruamel.yaml import YAML + import ruamel.yaml.comments + from ruamel.yaml.compat import StringIO + + yaml = YAML(typ='unsafe') + buf = StringIO() + yaml.dump(ruamel.yaml.comments.CommentedBase.yaml_anchor, buf) + res = buf.getvalue() + assert res == '!!python/name:ruamel.yaml.comments.CommentedBase.yaml_anchor \n...\n' + x = yaml.load(res) + assert x == ruamel.yaml.comments.CommentedBase.yaml_anchor |