Skip to content
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

Merged
merged 3 commits into from
Apr 11, 2017

Conversation

ojii
Copy link
Contributor

@ojii ojii commented Apr 10, 2017

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.

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.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.577% when pulling 08d83a5 on ojii:lastfailed-failedfirst into 83b241b on pytest-dev:features.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a 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

@ojii
Copy link
Contributor Author

ojii commented Apr 10, 2017

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.

Copy link
Member

@nicoddemus nicoddemus left a 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. 👍

# 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("""
Copy link
Member

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*",
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()

@nicoddemus
Copy link
Member

@ojii realized it was quicker to implement the changes myself and push to your fork (hope you don't mind). 😄

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.577% when pulling 1125786 on ojii:lastfailed-failedfirst into 83b241b on pytest-dev:features.

@nicoddemus nicoddemus merged commit 02da278 into pytest-dev:features Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants