# Path: srsly/tests/ruamel_yaml/roundtrip.py
# def save_and_run(program, base_dir=None, output=None, file_name=None, optimized=False):
#     """
#     safe and run a python program, thereby circumventing any restrictions on module level
#     imports
#     """
#     from subprocess import check_output, STDOUT, CalledProcessError
# 
#     if not hasattr(base_dir, "hash"):
#         base_dir = Path(str(base_dir))
#     if file_name is None:
#         file_name = "safe_and_run_tmp.py"
#     file_name = base_dir / file_name
#     file_name.write_text(dedent(program))
# 
#     try:
#         cmd = [sys.executable]
#         if optimized:
#             cmd.append("-O")
#         cmd.append(str(file_name))
#         print("running:", *cmd)
#         res = check_output(cmd, stderr=STDOUT, universal_newlines=True)
#         if output is not None:
#             if "__pypy__" in sys.builtin_module_names:
#                 res = res.splitlines(True)
#                 res = [line for line in res if "no version info" not in line]
#                 res = "".join(res)
#             print("result:  ", res, end="")
#             print("expected:", output, end="")
#             assert res == output
#     except CalledProcessError as exception:
#         print("##### Running '{} {}' FAILED #####".format(sys.executable, file_name))
#         print(exception.output)
#         return exception.returncode
#     return 0


import sys
import pytest  # NOQA
    import srsly.ruamel_yaml.comments
from .roundtrip import save_and_run  # NOQA
    from srsly.ruamel_yaml import YAML
    from srsly.ruamel_yaml.compat import StringIO
        ac: 16
        attacks: [BITE, HURT]
        hp: [2, 6]
        name: Cave spider
    """)
    '''
    assert save_and_run(program_src, tmpdir) == 1


@pytest.mark.skipif(sys.version_info < (3, 0), reason="no __qualname__")
def test_qualified_name00(tmpdir):
    """issue 214"""
    program_src = u"""\
    from srsly.ruamel_yaml import YAML
    from srsly.ruamel_yaml.compat import StringIO

    class A:
        def f(self):
            pass

    yaml = YAML(typ='unsafe', pure=True)
    yaml.explicit_end = True
    buf = StringIO()
    yaml.dump(A.f, buf)
    res = buf.getvalue()
    print('res', repr(res))
    assert res == "!!python/name:__main__.A.f ''\\n...\\n"
    x = yaml.load(res)
    assert x == A.f
    """

# Path: srsly/tests/ruamel_yaml/roundtrip.py
# def save_and_run(program, base_dir=None, output=None, file_name=None, optimized=False):
#     """
#     safe and run a python program, thereby circumventing any restrictions on module level
#     imports
#     """
#     from subprocess import check_output, STDOUT, CalledProcessError
# 
#     if not hasattr(base_dir, "hash"):
#         base_dir = Path(str(base_dir))
#     if file_name is None:
#         file_name = "safe_and_run_tmp.py"
#     file_name = base_dir / file_name
#     file_name.write_text(dedent(program))
# 
#     try:
#         cmd = [sys.executable]
#         if optimized:
#             cmd.append("-O")
#         cmd.append(str(file_name))
#         print("running:", *cmd)
#         res = check_output(cmd, stderr=STDOUT, universal_newlines=True)
#         if output is not None:
#             if "__pypy__" in sys.builtin_module_names:
#                 res = res.splitlines(True)
#                 res = [line for line in res if "no version info" not in line]
#                 res = "".join(res)
#             print("result:  ", res, end="")
#             print("expected:", output, end="")
#             assert res == output
#     except CalledProcessError as exception:
#         print("##### Running '{} {}' FAILED #####".format(sys.executable, file_name))
#         print(exception.output)
#         return exception.returncode
#     return 0


# Path: srsly/tests/ruamel_yaml/test_yamlobject.py
import sys
import pytest  # NOQA
    import srsly.ruamel_yaml.comments
from .roundtrip import save_and_run  # NOQA
    from srsly.ruamel_yaml import YAML
    from srsly.ruamel_yaml.compat import StringIO

        ac: 16
        attacks: [BITE, HURT]
        hp: [2, 6]
        name: Cave spider
    """)
    '''
    assert save_and_run(program_src, tmpdir) == 1


@pytest.mark.skipif(sys.version_info < (3, 0), reason="no __qualname__")
def test_qualified_name00(tmpdir):
    """issue 214"""
    program_src = u"""\
    from srsly.ruamel_yaml import YAML
    from srsly.ruamel_yaml.compat import StringIO

    class A:
        def f(self):
            pass

    yaml = YAML(typ='unsafe', pure=True)
    yaml.explicit_end = True
    buf = StringIO()
    yaml.dump(A.f, buf)
    res = buf.getvalue()
    print('res', repr(res))
    assert res == "!!python/name:__main__.A.f ''\\n...\\n"
    x = yaml.load(res)
    assert x == A.f
    """

    assert save_and_run(program_src, tmpdir) == 1