Skip to content

Commit 37dd47a

Browse files
committed
Restructured project.
1 parent 19e1204 commit 37dd47a

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

pytest_stepwise/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.4'

pytest_stepwise/compat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
try:
2+
from _pytest.cacheprovider import Cache
3+
except ImportError:
4+
from pytest_cache import Cache
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import pytest
2-
from pytest_cache import Cache
3-
4-
__version__ = '0.3'
2+
from .compat import Cache
53

64

75
def pytest_addoption(parser):
@@ -14,7 +12,7 @@ def pytest_addoption(parser):
1412
help='ignore the first failing test but stop on the next failing test')
1513

1614

17-
@pytest.mark.tryfirst
15+
@pytest.hookimpl(tryfirst=True)
1816
def pytest_configure(config):
1917
config.cache = Cache(config)
2018
config.pluginmanager.register(StepwisePlugin(config), 'stepwiseplugin')
@@ -58,6 +56,10 @@ def pytest_collection_modifyitems(self, session, config, items):
5856

5957
config.hook.pytest_deselected(items=already_passed)
6058

59+
def pytest_collectreport(self, report):
60+
if self.active and report.failed:
61+
self.session.shouldstop = 'Error when collecting test, stopping test execution.'
62+
6163
def pytest_runtest_logreport(self, report):
6264
# Skip this hook if plugin is not active or the test is xfailed.
6365
if not self.active or 'xfail' in report.keywords:

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111

1212
setup(
1313
name='pytest-stepwise',
14-
version='0.3',
14+
version=__import__('pytest_stepwise').__version__,
1515
author='Niclas Olofsson',
1616
author_email='n@niclasolofsson.se',
1717
maintainer='Niclas Olofsson',
@@ -20,13 +20,13 @@ def read(fname):
2020
url='https://github.com/nip3o/pytest-stepwise',
2121
description='Run a test suite one failing test at a time.',
2222
long_description=read('README.rst'),
23-
py_modules=['pytest_stepwise'],
23+
packages=['pytest_stepwise'],
2424
install_requires=['pytest-cache >= 1.0'],
2525
classifiers=['Development Status :: 4 - Beta',
2626
'Intended Audience :: Developers',
2727
'Topic :: Software Development :: Testing',
2828
'Programming Language :: Python',
2929
'Operating System :: OS Independent',
3030
'License :: OSI Approved :: MIT License'],
31-
entry_points={'pytest11': ['stepwise = pytest_stepwise']},
31+
entry_points={'pytest11': ['stepwise = pytest_stepwise.plugin']},
3232
)
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def test_success_after_fail():
5151
return testdir
5252

5353

54+
@pytest.fixture
55+
def broken_testdir(testdir):
56+
testdir.makepyfile(working_testfile='def test_proper(): assert 1', broken_testfile='foobar')
57+
return testdir
58+
59+
5460
def test_run_without_stepwise(stepwise_testdir):
5561
result = stepwise_testdir.runpytest('-v', '--strict', '--fail')
5662

@@ -121,3 +127,10 @@ def test_change_testfile(stepwise_testdir):
121127

122128
stdout = result.stdout.str()
123129
assert 'test_success PASSED' in stdout
130+
131+
132+
def test_stop_on_collection_errors(broken_testdir):
133+
result = broken_testdir.runpytest('-v', '--strict', '--stepwise', 'working_testfile.py', 'broken_testfile.py')
134+
135+
stdout = result.stdout.str()
136+
assert 'Error when collecting test' in stdout

0 commit comments

Comments
 (0)