def test_keyword_arguments(tempfiles):
    code = textwrap.dedent("""
    from unittest import TestCase
    from tests.support.helpers import requires_network

    @requires_network(only_local_network=True)
    class TestFoo(TestCase):

        def test_one(self):
            assert True
    """)
    expected_code = textwrap.dedent("""
    from unittest import TestCase

    import pytest

    @pytest.mark.requires_network(only_local_network=True)
    class TestFoo(TestCase):

        def test_one(self):
            assert True
    """)
    fpath = tempfiles.makepyfile(code, prefix="test_")
    fix_requires_network_decorator.rewrite(fpath)
    with open(fpath) as rfh:
        new_code = rfh.read()
    assert new_code == expected_code
def test_function_level(tempfiles):
    code = textwrap.dedent("""
    from unittest import TestCase
    from tests.support.helpers import requires_network

    class TestFoo(TestCase):

        @requires_network
        def test_one(self):
            assert True
    """)
    expected_code = textwrap.dedent("""
    from unittest import TestCase

    import pytest

    class TestFoo(TestCase):

        @pytest.mark.requires_network
        def test_one(self):
            assert True
    """)
    fpath = tempfiles.makepyfile(code, prefix="test_")
    fix_requires_network_decorator.rewrite(fpath)
    with open(fpath) as rfh:
        new_code = rfh.read()
    assert new_code == expected_code