Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <[email protected]>
  • Loading branch information
s0undt3ch committed Oct 20, 2023
1 parent b96be64 commit 8b1a428
Show file tree
Hide file tree
Showing 29 changed files with 763 additions and 3 deletions.
58 changes: 58 additions & 0 deletions tests/functional/test_skip_if_binaries_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_aarch64.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_aix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
62 changes: 62 additions & 0 deletions tests/functional/test_skip_on_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_netbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_openbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
25 changes: 25 additions & 0 deletions tests/functional/test_skip_on_photonos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
)
20 changes: 20 additions & 0 deletions tests/functional/test_skip_on_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
)
Loading

0 comments on commit 8b1a428

Please sign in to comment.