From e7ee850d46d54789979bf0c5244bae1825fb7149 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 22:19:53 +0200 Subject: Adding upstream version 0.91.0. Signed-off-by: Daniel Baumann --- _test/test_cyaml.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 _test/test_cyaml.py (limited to '_test/test_cyaml.py') diff --git a/_test/test_cyaml.py b/_test/test_cyaml.py new file mode 100644 index 0000000..b16c7ab --- /dev/null +++ b/_test/test_cyaml.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +import platform +import sys +from textwrap import dedent + +import pytest + +NO_CLIB_VER = (3, 10) + + +@pytest.mark.skipif( + platform.python_implementation() in ['Jython', 'PyPy'], + reason='Jython throws RepresenterError', +) +@pytest.mark.xfail(reason="cyaml not ported yet") +def test_load_cyaml(): + print("???????????????????????", platform.python_implementation()) + import ruyaml + + if sys.version_info >= NO_CLIB_VER: + return + yaml = ruyaml.YAML(typ='safe', pure=False) + assert ruyaml.__with_libyaml__ + + yaml.load('abc: 1') + + +@pytest.mark.skipif( + sys.version_info >= NO_CLIB_VER + or platform.python_implementation() in ['Jython', 'PyPy'], + reason='no _PyGC_FINALIZED', +) +def test_dump_cyaml(): + import ruyaml + + if sys.version_info >= NO_CLIB_VER: + return + data = {'a': 1, 'b': 2} + yaml = ruyaml.YAML(typ='safe', pure=False) + yaml.default_flow_style = False + yaml.allow_unicode = True + buf = ruyaml.compat.StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == 'a: 1\nb: 2\n' + + +@pytest.mark.skipif( + platform.python_implementation() in ['Jython', 'PyPy'], reason='not avialable' +) +@pytest.mark.xfail(reason="cyaml not ported yet") +def test_load_cyaml_1_2(): + # issue 155 + import ruyaml + + if sys.version_info >= NO_CLIB_VER: + return + assert ruyaml.__with_libyaml__ + inp = dedent( + """\ + %YAML 1.2 + --- + num_epochs: 70000 + """ + ) + yaml = ruyaml.YAML(typ='safe') + yaml.load(inp) + + +@pytest.mark.skipif( + platform.python_implementation() in ['Jython', 'PyPy'], reason='not available' +) +@pytest.mark.xfail(reason="cyaml not ported yet") +def test_dump_cyaml_1_2(): + # issue 155 + from io import StringIO + + import ruyaml + + if sys.version_info >= NO_CLIB_VER: + return + assert ruyaml.__with_libyaml__ + yaml = ruyaml.YAML(typ='safe') + yaml.version = (1, 2) + yaml.default_flow_style = False + data = {'a': 1, 'b': 2} + exp = dedent( + """\ + %YAML 1.2 + --- + a: 1 + b: 2 + """ + ) + buf = StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == exp -- cgit v1.2.3