update for builtin plugin

This commit is contained in:
David Szotten 2018-10-14 12:58:11 +01:00
parent c56d7ac40e
commit 63c01d1541
3 changed files with 14 additions and 14 deletions

View File

@ -126,6 +126,7 @@ default_plugins = (
"freeze_support",
"setuponly",
"setupplan",
"stepwise",
"warnings",
"logging",
)

View File

@ -1,19 +1,18 @@
from .compat import Cache, tryfirst
from _pytest.cacheprovider import Cache
import pytest
def pytest_addoption(parser):
group = parser.getgroup('general')
group.addoption('--sw', action='store_true', dest='stepwise',
help='alias for --stepwise')
group.addoption('--stepwise', action='store_true', dest='stepwise',
group.addoption('--sw', '--stepwise', action='store_true', dest='stepwise',
help='exit on test fail and continue from last failing test next time')
group.addoption('--skip', action='store_true', dest='skip',
group.addoption('--stepwise-skip', action='store_true', dest='stepwise_skip',
help='ignore the first failing test but stop on the next failing test')
@tryfirst
@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
config.cache = Cache(config)
config.cache = Cache.for_config(config)
config.pluginmanager.register(StepwisePlugin(config), 'stepwiseplugin')
@ -25,7 +24,7 @@ class StepwisePlugin:
if self.active:
self.lastfailed = config.cache.get('cache/stepwise', None)
self.skip = config.getvalue('skip')
self.skip = config.getvalue('stepwise_skip')
def pytest_sessionstart(self, session):
self.session = session

View File

@ -13,7 +13,7 @@ def pytest_addoption(parser):
''')
# Create a simple test suite.
testdir.makepyfile(test_stepwise='''
testdir.makepyfile(test_a='''
def test_success_before_fail():
assert 1
@ -30,7 +30,7 @@ def test_success_after_last_fail():
assert 1
''')
testdir.makepyfile(testfile_b='''
testdir.makepyfile(test_b='''
def test_success():
assert 1
''')
@ -40,7 +40,7 @@ def test_success():
@pytest.fixture
def error_testdir(testdir):
testdir.makepyfile(test_stepwise='''
testdir.makepyfile(test_a='''
def test_error(nonexisting_fixture):
assert 1
@ -88,7 +88,7 @@ def test_fail_and_continue_with_stepwise(stepwise_testdir):
def test_run_with_skip_option(stepwise_testdir):
result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--skip',
result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--stepwise-skip',
'--fail', '--fail-last')
assert not result.stderr.str()
@ -112,7 +112,7 @@ def test_fail_on_errors(error_testdir):
def test_change_testfile(stepwise_testdir):
result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--fail',
'test_stepwise.py')
'test_a.py')
assert not result.stderr.str()
stdout = result.stdout.str()
@ -121,7 +121,7 @@ def test_change_testfile(stepwise_testdir):
# Make sure the second test run starts from the beginning, since the
# test to continue from does not exist in testfile_b.
result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise',
'testfile_b.py')
'test_b.py')
assert not result.stderr.str()
stdout = result.stdout.str()