Add support for the --run-slow flag into pytest

This commit is contained in:
Pedro Algarvio 2020-05-08 18:34:50 +01:00 committed by Daniel Wozniak
parent 5652183063
commit d889ff7fbc
15 changed files with 27 additions and 14 deletions

View file

@ -2,7 +2,7 @@ mock >= 3.0.0
# PyTest
pytest >=4.6.9,<4.7 # PyTest 4.6.x are the last Py2 and Py3 releases
pytest-salt
pytest-salt-factories >= 0.10.0
pytest-salt-factories >= 0.10.5
pytest-tempdir >= 2019.10.12
pytest-helpers-namespace >= 2019.1.8
pytest-salt-runtests-bridge >= 2019.12.5

View file

@ -88,7 +88,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -84,7 +84,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -78,7 +78,7 @@ pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -87,7 +87,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -83,7 +83,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -77,7 +77,7 @@ pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -86,7 +86,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -83,7 +83,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -76,7 +76,7 @@ pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -85,7 +85,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -83,7 +83,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -85,7 +85,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -83,7 +83,7 @@ pyopenssl==19.0.0
pyparsing==2.4.5 # via junos-eznc, packaging
pyserial==3.4 # via junos-eznc
pytest-helpers-namespace==2019.1.8
pytest-salt-factories==0.10.4
pytest-salt-factories==0.10.5
pytest-salt-runtests-bridge==2019.12.5
pytest-salt==2020.1.27
pytest-tempdir==2019.10.12

View file

@ -35,6 +35,7 @@ import salt.utils.files
import salt.utils.path
import salt.utils.platform
import salt.utils.win_functions
import saltfactories.utils.compat
from _pytest.mark.evaluate import MarkEvaluator
from salt.ext import six
from salt.serializers import yaml
@ -156,6 +157,10 @@ def pytest_addoption(parser):
default=False,
help="Run proxy tests",
)
test_selection_group.addoption(
"--run-slow", action="store_true", default=False, help="Run slow tests.",
)
output_options_group = parser.getgroup("Output Options")
output_options_group.addoption(
"--output-columns",
@ -219,6 +224,9 @@ def pytest_configure(config):
# Make sure the test suite "knows" this is a pytest test run
RUNTIME_VARS.PYTEST_SESSION = True
# "Flag" the slotTest decorator if we're skipping slow tests or not
os.environ["SLOW_TESTS"] = str(config.getoption("--run-slow"))
# <---- Register Markers ---------------------------------------------------------------------------------------------
@ -435,6 +443,11 @@ def pytest_runtest_setup(item):
item._skipped_by_mark = True
pytest.skip(PRE_PYTEST_SKIP_REASON)
if saltfactories.utils.compat.has_unittest_attr(item, "__slow_test__"):
if item.config.getoption("--run-slow") is False:
item._skipped_by_mark = True
pytest.skip("Slow tests are disabled!")
requires_salt_modules_marker = item.get_closest_marker("requires_salt_modules")
if requires_salt_modules_marker is not None:
required_salt_modules = requires_salt_modules_marker.args