-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Changed behavior if --lf and --ff are both used. #2357
Conversation
When using both --last-failed/--lf and --failed-first/--ff pytest would run all tests with failed tests first (as if --lf was not provied). This patch changes it so that when using both flags, only the last failed tests are run. This makes it easier to set --ff as the default behavior via the config file and then selectively use --lf to only run the last failed tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i think i'll be fine with pushing this into 3.1 after all, good work and thanks :)
this is a beautifully executed pr both on formal and technical level
Thank you. The pull request template (with the checklist) really helped me make sure this PR is somewhat well formed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ojii thanks a lot for the PR. Like @RonnyPfannschmidt mentioned already, this looks great!
I made two small comments regarding the test; if you have the time to do them great, otherwise let me know and I can finish the PR. 👍
testing/test_cache.py
Outdated
# 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.tmpdir.join('test_a.py').write(_pytest._code.Source(""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files can be created more easily like this:
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
"""),
})
But this is just FYI really, no need to actually change it.
result = testdir.runpytest("--lf", "--ff") | ||
# Test order will be failing tests firs | ||
result.stdout.fnmatch_lines([ | ||
"test_b.py*", |
There was a problem hiding this comment.
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()
@ojii realized it was quicker to implement the changes myself and push to your fork (hope you don't mind). 😄 |
When using both --last-failed/--lf and --failed-first/--ff pytest would
run all tests with failed tests first (as if --lf was not provied). This
patch changes it so that when using both flags, only the last failed
tests are run. This makes it easier to set --ff as the default behavior
via the config file and then selectively use --lf to only run the last
failed tests.