-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
#3823 Fix trace option for unittest test cases #4083
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
Closed
bkjchoi72
wants to merge
4
commits into
pytest-dev:master
from
bkjchoi72:3823-add-trace-option-for-unittest
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed the ``--trace`` option so that it works with unittest test cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
something about this change sits very wrong with me i will require a deeper review of the interaction, cause it just looks "wrong" - it cant be right to just invoke the hook that way
Uh oh!
There was an error while loading. Please reload this page.
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.
after tracing the code for the trace plug-in and the debugging plug-in as well as the unittest plug-in, i believe this code will trigger double test execution when tracing
Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for the insight @RonnyPfannschmidt . Could you elaborate on why or how this triggers double test execution, how I can reproduce it, and possibly some ideas on how I can go about invoking the hook in a different way?
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.
the double code execution happens due to in addition to running the normal test code below, when tracing calling the hook
i believe calling the hook itself is not fitting the intent of the unittest integration (as we explicitly invoke the testcase machinery of unittest for setup/teardown behaviour)
so in addition of the double test call, i believe the pyfunc_call based code additionally also skips the unittest setup/teardown machinery for the per test "scope"
to be honest without a own deeper investigation i have no idea where to actually hook in to make this "right"
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.
Got it. Let me play with this over the weekend and see if I can come up with something.
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.
@RonnyPfannschmidt I want to clarify the behavior of the trace plugin when the test case has a setUp() method. Let's say I have the following test case:
When you run pytest with trace option, should this break on line 4, or line 6?
What I find interesting is that if we have a pytest function with a fixture, the break starts at the function, not the fixture. For example, let's say we have the following test:
Running pytest with trace option will break at line 6. If we want to be consistent, running the trace option on a unittest style test case should break at the actual test, not the setup. Is this the correct behavior?
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.
yes, break at the start of the test is the intended behaviour