diff --git a/tests/functional/test_skip_if_binaries_missing.py b/tests/functional/test_skip_if_binaries_missing.py index 2e52217..e2bc249 100644 --- a/tests/functional/test_skip_if_binaries_missing.py +++ b/tests/functional/test_skip_if_binaries_missing.py @@ -77,3 +77,61 @@ def test_one(): res = pytester.runpytest_subprocess("-ra", "-vv") res.assert_outcomes(passed=1) res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + + +def test_single_non_existing_with_deprecated_message(pytester, python_binary): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_if_binaries_missing("python9", message="Dam!") + def test_one(): + assert True + """ + ) + res = pytester.runpytest_subprocess("-ra", "-vv") + res.assert_outcomes(skipped=1) + res.stdout.fnmatch_lines( + [ + """*: PytestWarning: Please stop passing 'message="Dam!"' and instead pass 'reason="Dam!"'""" + ] + ) + + +def test_no_arguments(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_if_binaries_missing + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.fnmatch_lines( + [ + "*UsageError: The 'skip_if_binaries_missing' marker needs at least one binary name to be passed" + ] + ) + + +def test_multiple_binaries_as_single_list_arg(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_if_binaries_missing(["python", "python9"]) + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.fnmatch_lines( + [ + "*UsageError: The 'skip_if_binaries_missing' marker only accepts strings as arguments. If you are " + "trying to pass multiple binaries, each binary should be an separate argument." + ] + ) diff --git a/tests/functional/test_skip_on_aarch64.py b/tests/functional/test_skip_on_aarch64.py index 9b0a065..3507caf 100644 --- a/tests/functional/test_skip_on_aarch64.py +++ b/tests/functional/test_skip_on_aarch64.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_aarch64("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_aarch64(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_aarch64 marker does not accept any arguments", + "*UsageError: The skip_on_aarch64 marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_aix.py b/tests/functional/test_skip_on_aix.py index e150230..b4e21a6 100644 --- a/tests/functional/test_skip_on_aix.py +++ b/tests/functional/test_skip_on_aix.py @@ -69,3 +69,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_aix("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_aix(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_aix marker does not accept any arguments", + "*UsageError: The skip_on_aix marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_darwin.py b/tests/functional/test_skip_on_darwin.py index 43dc560..707ac50 100644 --- a/tests/functional/test_skip_on_darwin.py +++ b/tests/functional/test_skip_on_darwin.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_darwin("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_darwin(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_darwin marker does not accept any arguments", + "*UsageError: The skip_on_darwin marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_env.py b/tests/functional/test_skip_on_env.py index 5e325b6..57dc570 100644 --- a/tests/functional/test_skip_on_env.py +++ b/tests/functional/test_skip_on_env.py @@ -50,3 +50,65 @@ def test_one(): res = pytester.runpytest_inprocess() res.assert_outcomes(passed=1) res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + + +def test_error_on_missing_arg(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_env + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The 'skip_on_env' marker needs at least one argument to be passed, " + "the environment variable name.", + ] + ) + + +def test_error_on_multiple_args(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_env("FOOBAR", "BARFOO", eq="2") + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The 'skip_on_env' only accepts one argument, the environment variable name.", + ] + ) + + +def test_error_on_bad_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_env("FOOBAR", eq="2", bar=True) + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The 'skip_on_env' marker only accepts 'present', 'eq', 'ne' and 'reason' " + "as keyword arguments.", + ] + ) diff --git a/tests/functional/test_skip_on_freebsd.py b/tests/functional/test_skip_on_freebsd.py index 60fc2bf..1776e60 100644 --- a/tests/functional/test_skip_on_freebsd.py +++ b/tests/functional/test_skip_on_freebsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_freebsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_freebsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_freebsd marker does not accept any arguments", + "*UsageError: The skip_on_freebsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_linux.py b/tests/functional/test_skip_on_linux.py index 87a7af9..b5f40fb 100644 --- a/tests/functional/test_skip_on_linux.py +++ b/tests/functional/test_skip_on_linux.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_linux("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_linux(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_linux marker does not accept any arguments", + "*UsageError: The skip_on_linux marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_netbsd.py b/tests/functional/test_skip_on_netbsd.py index d8fcb22..07b84fd 100644 --- a/tests/functional/test_skip_on_netbsd.py +++ b/tests/functional/test_skip_on_netbsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_netbsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_netbsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_netbsd marker does not accept any arguments", + "*UsageError: The skip_on_netbsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_openbsd.py b/tests/functional/test_skip_on_openbsd.py index 39eaf93..be92136 100644 --- a/tests/functional/test_skip_on_openbsd.py +++ b/tests/functional/test_skip_on_openbsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_openbsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_openbsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_openbsd marker does not accept any arguments", + "*UsageError: The skip_on_openbsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_photonos.py b/tests/functional/test_skip_on_photonos.py index 0e62ba1..74b56cf 100644 --- a/tests/functional/test_skip_on_photonos.py +++ b/tests/functional/test_skip_on_photonos.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_photonos("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_photonos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_photonos marker does not accept any arguments", + "*UsageError: The skip_on_photonos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_platforms.py b/tests/functional/test_skip_on_platforms.py index fe83960..cca2140 100644 --- a/tests/functional/test_skip_on_platforms.py +++ b/tests/functional/test_skip_on_platforms.py @@ -155,3 +155,23 @@ def test_one(): "on_platforms() got an unexpected keyword argument 'car'" ] ) + + +def test_error_on_args(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_platforms("arg") + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=1) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_platforms marker does not accept any arguments", + ] + ) diff --git a/tests/functional/test_skip_on_smartos.py b/tests/functional/test_skip_on_smartos.py index da48ce4..1f6127d 100644 --- a/tests/functional/test_skip_on_smartos.py +++ b/tests/functional/test_skip_on_smartos.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_smartos("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_smartos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_smartos marker does not accept any arguments", + "*UsageError: The skip_on_smartos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_spawning_platform.py b/tests/functional/test_skip_on_spawning_platform.py index ff026f4..c18d4c0 100644 --- a/tests/functional/test_skip_on_spawning_platform.py +++ b/tests/functional/test_skip_on_spawning_platform.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_spawning_platform("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_spawning_platform(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_spawning_platform marker does not accept any arguments", + "*UsageError: The skip_on_spawning_platform marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_sunos.py b/tests/functional/test_skip_on_sunos.py index 62e3a7a..92a7f36 100644 --- a/tests/functional/test_skip_on_sunos.py +++ b/tests/functional/test_skip_on_sunos.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_sunos("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_sunos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_sunos marker does not accept any arguments", + "*UsageError: The skip_on_sunos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_on_windows.py b/tests/functional/test_skip_on_windows.py index 4412885..9df379f 100644 --- a/tests/functional/test_skip_on_windows.py +++ b/tests/functional/test_skip_on_windows.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_on_windows("arg") + def test_one(): + assert True + + @pytest.mark.skip_on_windows(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_on_windows marker does not accept any arguments", + "*UsageError: The skip_on_windows marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_aarch64.py b/tests/functional/test_skip_unless_on_aarch64.py index e7490c5..e60674a 100644 --- a/tests/functional/test_skip_unless_on_aarch64.py +++ b/tests/functional/test_skip_unless_on_aarch64.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_aarch64("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_aarch64(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_aarch64 marker does not accept any arguments", + "*UsageError: The skip_unless_on_aarch64 marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_aix.py b/tests/functional/test_skip_unless_on_aix.py index 55b6682..3b33279 100644 --- a/tests/functional/test_skip_unless_on_aix.py +++ b/tests/functional/test_skip_unless_on_aix.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_aix("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_aix(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_aix marker does not accept any arguments", + "*UsageError: The skip_unless_on_aix marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_darwin.py b/tests/functional/test_skip_unless_on_darwin.py index d99fe39..7fa2003 100644 --- a/tests/functional/test_skip_unless_on_darwin.py +++ b/tests/functional/test_skip_unless_on_darwin.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_darwin("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_darwin(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_darwin marker does not accept any arguments", + "*UsageError: The skip_unless_on_darwin marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_freebsd.py b/tests/functional/test_skip_unless_on_freebsd.py index 7a42b1d..c54520a 100644 --- a/tests/functional/test_skip_unless_on_freebsd.py +++ b/tests/functional/test_skip_unless_on_freebsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_freebsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_freebsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_freebsd marker does not accept any arguments", + "*UsageError: The skip_unless_on_freebsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_linux.py b/tests/functional/test_skip_unless_on_linux.py index 0f611c9..e10e3e7 100644 --- a/tests/functional/test_skip_unless_on_linux.py +++ b/tests/functional/test_skip_unless_on_linux.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_linux("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_linux(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_linux marker does not accept any arguments", + "*UsageError: The skip_unless_on_linux marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_netbsd.py b/tests/functional/test_skip_unless_on_netbsd.py index f35f900..81b9bb1 100644 --- a/tests/functional/test_skip_unless_on_netbsd.py +++ b/tests/functional/test_skip_unless_on_netbsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_netbsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_netbsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_netbsd marker does not accept any arguments", + "*UsageError: The skip_unless_on_netbsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_openbsd.py b/tests/functional/test_skip_unless_on_openbsd.py index 71660d0..c3a9a49 100644 --- a/tests/functional/test_skip_unless_on_openbsd.py +++ b/tests/functional/test_skip_unless_on_openbsd.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_openbsd("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_openbsd(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_openbsd marker does not accept any arguments", + "*UsageError: The skip_unless_on_openbsd marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_photonos.py b/tests/functional/test_skip_unless_on_photonos.py index c04138a..49bd15b 100644 --- a/tests/functional/test_skip_unless_on_photonos.py +++ b/tests/functional/test_skip_unless_on_photonos.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_photonos("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_photonos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_photonos marker does not accept any arguments", + "*UsageError: The skip_unless_on_photonos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_platforms.py b/tests/functional/test_skip_unless_on_platforms.py index 70c8f49..995672b 100644 --- a/tests/functional/test_skip_unless_on_platforms.py +++ b/tests/functional/test_skip_unless_on_platforms.py @@ -168,3 +168,23 @@ def test_one(): "on_platforms() got an unexpected keyword argument 'car'" ] ) + + +def test_error_on_args(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_platforms("arg") + def test_one(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_platforms marker does not accept any arguments", + ] + ) diff --git a/tests/functional/test_skip_unless_on_smartos.py b/tests/functional/test_skip_unless_on_smartos.py index 89ee440..8582d2d 100644 --- a/tests/functional/test_skip_unless_on_smartos.py +++ b/tests/functional/test_skip_unless_on_smartos.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_smartos("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_smartos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_smartos marker does not accept any arguments", + "*UsageError: The skip_unless_on_smartos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_spawning_platform.py b/tests/functional/test_skip_unless_on_spawning_platform.py index a33b910..8f0ab0f 100644 --- a/tests/functional/test_skip_unless_on_spawning_platform.py +++ b/tests/functional/test_skip_unless_on_spawning_platform.py @@ -65,3 +65,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_spawning_platform("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_spawning_platform(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_spawning_platform marker does not accept any arguments", + "*UsageError: The skip_unless_on_spawning_platform marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_sunos.py b/tests/functional/test_skip_unless_on_sunos.py index 931cd24..080aa6c 100644 --- a/tests/functional/test_skip_unless_on_sunos.py +++ b/tests/functional/test_skip_unless_on_sunos.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_sunos("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_sunos(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_sunos marker does not accept any arguments", + "*UsageError: The skip_unless_on_sunos marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/functional/test_skip_unless_on_windows.py b/tests/functional/test_skip_unless_on_windows.py index f72b435..1871ab5 100644 --- a/tests/functional/test_skip_unless_on_windows.py +++ b/tests/functional/test_skip_unless_on_windows.py @@ -68,3 +68,28 @@ def test_one(): res = pytester.runpytest_inprocess("-ra", "-s", "-vv") res.assert_outcomes(skipped=1) res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) + + +def test_error_on_args_or_kwargs(pytester): + pytester.makepyfile( + """ + import pytest + + @pytest.mark.skip_unless_on_windows("arg") + def test_one(): + assert True + + @pytest.mark.skip_unless_on_windows(kwarg="arg") + def test_two(): + assert True + """ + ) + res = pytester.runpytest() + res.assert_outcomes(errors=2) + res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") + res.stdout.fnmatch_lines( + [ + "*UsageError: The skip_unless_on_windows marker does not accept any arguments", + "*UsageError: The skip_unless_on_windows marker only accepts 'reason' as a keyword argument.", + ] + ) diff --git a/tests/unit/utils/markers/test_skip_if_binaries_missing.py b/tests/unit/utils/markers/test_skip_if_binaries_missing.py index 73cec75..3b83332 100644 --- a/tests/unit/utils/markers/test_skip_if_binaries_missing.py +++ b/tests/unit/utils/markers/test_skip_if_binaries_missing.py @@ -25,7 +25,7 @@ def test_multiple_existing(python_binary): assert markers.skip_if_binaries_missing([python_binary, "pip"]) is None -def test_single_non_existing_with_message(): +def test_single_non_existing_with_reason(): reason = markers.skip_if_binaries_missing(["python9"], reason="Dam!") assert reason is not None assert reason == "Dam!" @@ -52,7 +52,7 @@ def test_multiple_one_missing_check_all_false(python_binary): assert reason is None, reason -def test_multiple_one_missing_check_all_false_with_message(python_binary): +def test_multiple_one_missing_check_all_false_with_reason(python_binary): reason = markers.skip_if_binaries_missing( [python_binary, "pip9"], reason="Dam!", check_all=False ) @@ -66,7 +66,7 @@ def test_multiple_missing_check_all_false(): assert reason == "None of the following binaries was found: python9, pip9" -def test_multiple_missing_check_all_false_with_message(): +def test_multiple_missing_check_all_false_with_reason(): reason = markers.skip_if_binaries_missing(["python9", "pip9"], reason="Dam!", check_all=False) assert reason is not None assert reason == "Dam!"