Merge pull request #2357 from ojii/lastfailed-failedfirst
Changed behavior if --lf and --ff are both used.
This commit is contained in:
commit
02da278894
1
AUTHORS
1
AUTHORS
|
@ -78,6 +78,7 @@ Javier Romero
|
||||||
Jeff Widman
|
Jeff Widman
|
||||||
John Towler
|
John Towler
|
||||||
Jon Sonesen
|
Jon Sonesen
|
||||||
|
Jonas Obrist
|
||||||
Jordan Guymon
|
Jordan Guymon
|
||||||
Joshua Bronson
|
Joshua Bronson
|
||||||
Jurko Gospodnetić
|
Jurko Gospodnetić
|
||||||
|
|
|
@ -69,6 +69,9 @@ Changes
|
||||||
* ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
|
* ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
|
||||||
Thanks `@reutsharabani`_ for the PR.
|
Thanks `@reutsharabani`_ for the PR.
|
||||||
|
|
||||||
|
* fix `#2308`_: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
|
||||||
|
Thanks `@ojii`_ for the PR.
|
||||||
|
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------
|
---------
|
||||||
|
@ -88,6 +91,7 @@ Bug Fixes
|
||||||
.. _@reutsharabani: https://github.com/reutsharabani
|
.. _@reutsharabani: https://github.com/reutsharabani
|
||||||
.. _@unsignedint: https://github.com/unsignedint
|
.. _@unsignedint: https://github.com/unsignedint
|
||||||
.. _@Kriechi: https://github.com/Kriechi
|
.. _@Kriechi: https://github.com/Kriechi
|
||||||
|
.. _@ojii: https://github.com/ojii
|
||||||
|
|
||||||
|
|
||||||
.. _#1407: https://github.com/pytest-dev/pytest/issues/1407
|
.. _#1407: https://github.com/pytest-dev/pytest/issues/1407
|
||||||
|
@ -101,6 +105,7 @@ Bug Fixes
|
||||||
.. _#2147: https://github.com/pytest-dev/pytest/issues/2147
|
.. _#2147: https://github.com/pytest-dev/pytest/issues/2147
|
||||||
.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
|
.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
|
||||||
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
|
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
|
||||||
|
.. _#2308: https://github.com/pytest-dev/pytest/issues/2308
|
||||||
|
|
||||||
|
|
||||||
3.0.8 (unreleased)
|
3.0.8 (unreleased)
|
||||||
|
|
|
@ -139,11 +139,11 @@ class LFPlugin(object):
|
||||||
# running a subset of all tests with recorded failures outside
|
# running a subset of all tests with recorded failures outside
|
||||||
# of the set of tests currently executing
|
# of the set of tests currently executing
|
||||||
pass
|
pass
|
||||||
elif self.config.getvalue("failedfirst"):
|
elif self.config.getvalue("lf"):
|
||||||
items[:] = previously_failed + previously_passed
|
|
||||||
else:
|
|
||||||
items[:] = previously_failed
|
items[:] = previously_failed
|
||||||
config.hook.pytest_deselected(items=previously_passed)
|
config.hook.pytest_deselected(items=previously_passed)
|
||||||
|
else:
|
||||||
|
items[:] = previously_failed + previously_passed
|
||||||
|
|
||||||
def pytest_sessionfinish(self, session):
|
def pytest_sessionfinish(self, session):
|
||||||
config = self.config
|
config = self.config
|
||||||
|
|
|
@ -192,13 +192,37 @@ class TestLastFailed(object):
|
||||||
"test_a.py*",
|
"test_a.py*",
|
||||||
"test_b.py*",
|
"test_b.py*",
|
||||||
])
|
])
|
||||||
result = testdir.runpytest("--lf", "--ff")
|
result = testdir.runpytest("--ff")
|
||||||
# Test order will be failing tests firs
|
# Test order will be failing tests firs
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"test_b.py*",
|
"test_b.py*",
|
||||||
"test_a.py*",
|
"test_a.py*",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_lastfailed_failedfirst_order(self, testdir):
|
||||||
|
testdir.makepyfile(**{
|
||||||
|
'test_a.py': """
|
||||||
|
def test_always_passes():
|
||||||
|
assert 1
|
||||||
|
""",
|
||||||
|
'test_b.py': """
|
||||||
|
def test_always_fails():
|
||||||
|
assert 0
|
||||||
|
""",
|
||||||
|
})
|
||||||
|
result = testdir.runpytest()
|
||||||
|
# Test order will be collection order; alphabetical
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"test_a.py*",
|
||||||
|
"test_b.py*",
|
||||||
|
])
|
||||||
|
result = testdir.runpytest("--lf", "--ff")
|
||||||
|
# Test order will be failing tests firs
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"test_b.py*",
|
||||||
|
])
|
||||||
|
assert 'test_a.py' not in result.stdout.str()
|
||||||
|
|
||||||
def test_lastfailed_difference_invocations(self, testdir, monkeypatch):
|
def test_lastfailed_difference_invocations(self, testdir, monkeypatch):
|
||||||
monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
|
monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
|
||||||
testdir.makepyfile(test_a="""
|
testdir.makepyfile(test_a="""
|
||||||
|
|
Loading…
Reference in New Issue