@@ -50,3 +50,65 @@ def test_one():
5050 res = pytester .runpytest_inprocess ()
5151 res .assert_outcomes (passed = 1 )
5252 res .stdout .no_fnmatch_line ("*PytestUnknownMarkWarning*" )
53+
54+
55+ def test_error_on_missing_arg (pytester ):
56+ pytester .makepyfile (
57+ """
58+ import pytest
59+
60+ @pytest.mark.skip_on_env
61+ def test_one():
62+ assert True
63+ """
64+ )
65+ res = pytester .runpytest ()
66+ res .assert_outcomes (errors = 1 )
67+ res .stdout .no_fnmatch_line ("*PytestUnknownMarkWarning*" )
68+ res .stdout .fnmatch_lines (
69+ [
70+ "*UsageError: The 'skip_on_env' marker needs at least one argument to be passed, "
71+ "the environment variable name." ,
72+ ]
73+ )
74+
75+
76+ def test_error_on_multiple_args (pytester ):
77+ pytester .makepyfile (
78+ """
79+ import pytest
80+
81+ @pytest.mark.skip_on_env("FOOBAR", "BARFOO", eq="2")
82+ def test_one():
83+ assert True
84+ """
85+ )
86+ res = pytester .runpytest ()
87+ res .assert_outcomes (errors = 1 )
88+ res .stdout .no_fnmatch_line ("*PytestUnknownMarkWarning*" )
89+ res .stdout .fnmatch_lines (
90+ [
91+ "*UsageError: The 'skip_on_env' only accepts one argument, the environment variable name." ,
92+ ]
93+ )
94+
95+
96+ def test_error_on_bad_kwargs (pytester ):
97+ pytester .makepyfile (
98+ """
99+ import pytest
100+
101+ @pytest.mark.skip_on_env("FOOBAR", eq="2", bar=True)
102+ def test_one():
103+ assert True
104+ """
105+ )
106+ res = pytester .runpytest ()
107+ res .assert_outcomes (errors = 1 )
108+ res .stdout .no_fnmatch_line ("*PytestUnknownMarkWarning*" )
109+ res .stdout .fnmatch_lines (
110+ [
111+ "*UsageError: The 'skip_on_env' marker only accepts 'present', 'eq', 'ne' and 'reason' "
112+ "as keyword arguments." ,
113+ ]
114+ )
0 commit comments