Skip to content

Changed behavior if --lf and --ff are both used. #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Javier Romero
Jeff Widman
John Towler
Jon Sonesen
Jonas Obrist
Jordan Guymon
Joshua Bronson
Jurko Gospodnetić
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Changes
* ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
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
---------
Expand All @@ -88,6 +91,7 @@ Bug Fixes
.. _@reutsharabani: https://github.com/reutsharabani
.. _@unsignedint: https://github.com/unsignedint
.. _@Kriechi: https://github.com/Kriechi
.. _@ojii: https://github.com/ojii


.. _#1407: https://github.com/pytest-dev/pytest/issues/1407
Expand All @@ -101,6 +105,7 @@ Bug Fixes
.. _#2147: https://github.com/pytest-dev/pytest/issues/2147
.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
.. _#2308: https://github.com/pytest-dev/pytest/issues/2308


3.0.8 (unreleased)
Expand Down
6 changes: 3 additions & 3 deletions _pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def pytest_collection_modifyitems(self, session, config, items):
# running a subset of all tests with recorded failures outside
# of the set of tests currently executing
pass
elif self.config.getvalue("failedfirst"):
items[:] = previously_failed + previously_passed
else:
elif self.config.getvalue("lf"):
items[:] = previously_failed
config.hook.pytest_deselected(items=previously_passed)
else:
items[:] = previously_failed + previously_passed

def pytest_sessionfinish(self, session):
config = self.config
Expand Down
26 changes: 25 additions & 1 deletion testing/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,37 @@ def test_always_fails():
"test_a.py*",
"test_b.py*",
])
result = testdir.runpytest("--lf", "--ff")
result = testdir.runpytest("--ff")
# Test order will be failing tests firs
result.stdout.fnmatch_lines([
"test_b.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*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice here to ensure that test_a did not run:

result.stdout.fnmatch_lines([
    "test_b.py*",
])
assert 'test_a' not in result.stdout.str()

])
assert 'test_a.py' not in result.stdout.str()

def test_lastfailed_difference_invocations(self, testdir, monkeypatch):
monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
testdir.makepyfile(test_a="""
Expand Down