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

Fix reported location of skip when --runxfail is used #7432

Merged
merged 6 commits into from Jul 9, 2020

Conversation

AFirouzi
Copy link
Contributor

@AFirouzi AFirouzi commented Jun 29, 2020

Fixes #7392.

Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

Hey @AFirouzi thank you for the PR!

Can you please also include the following?

@AFirouzi
Copy link
Contributor Author

Hey @AFirouzi thank you for the PR!

Can you please also include the following?

* A [changelog as explained here](https://github.com/pytest-dev/pytest/blob/master/CONTRIBUTING.rst#preparing-pull-requests)

* Tests for this change.

Sorry, I am a newbie here. If I got your point correctly, I need to write a test for this specific bug right? which in this case is it should be add to the test_skipping.py

@gnikonorov
Copy link
Member

@AFirouzi yes please. I think test_skipping.py sounds like a great place to put it

Also, consider using github keywords to close any linked issues otherwise someone has to manually close them. It also has the benefit of showing in the issue that there is a linked PR, so people know someone has a solution up for review

testing/test_skipping.py Outdated Show resolved Hide resolved
@AFirouzi
Copy link
Contributor Author

Fixes #7392

Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

Reading over the issue, it would appear that the issue is the reporting.

Adding --runxfail shows the error as coming from src/_pytest/skipping.py, but it should show the test file (e.g.: test_it.py ). Can you update the tests to check for this condition? I don't see the tests checking the file location outputted

@bluetech please correct me if I'm wrong

@bluetech
Copy link
Member

bluetech commented Jul 1, 2020

@gnikonorov is right, the problem is not what the current changelog entry states, but merely that --runxfail breaks the skip message.

The fix is also not quite right; the actual problem is that the "change the location of the failure to point to the item definition" code is currently dependent on previous conditions (uses elif), but really it shouldn't be (it should just use if).

@AFirouzi
Copy link
Contributor Author

AFirouzi commented Jul 1, 2020

Now I think I got the issue right. I just needed to simply replace last elif with if.
thank you @gnikonorov @bluetech
I hope I got it right this time.

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @AFirouzi. I left some comments.

src/_pytest/skipping.py Show resolved Hide resolved
changelog/7392.bugfix.rst Outdated Show resolved Hide resolved
testing/test_skipping.py Show resolved Hide resolved
@bluetech bluetech changed the title Fix issue 7392 Fix reported location of skip when --runxfail is used Jul 1, 2020
@bluetech
Copy link
Member

bluetech commented Jul 1, 2020

(I edited the PR title to be more descriptive, and added Fixes #7392. to the description so the PR is linked with the issue)

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Looks good now, thanks @AFirouzi!

@bluetech bluetech merged commit c3e2b11 into pytest-dev:master Jul 9, 2020
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.

skipping: --runxfail breaks pytest.mark.skip location reporting
3 participants