-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Teardown function's logs not captured #127
Comments
Thanks for the report. It looks like tear down logs are handled differently internally by pytest. I'll see what to do. |
The reason for the above is that output from the setup and teardown test phases is only processed if these phases fail: spyder-unittest/spyder_unittest/backend/pytestworker.py Lines 72 to 73 in 8acab5d
This is caused by different approaches taken by
So instead of sending the result of each test phase (except for passing setup/teardown phases) from the I think the processing (accumulation) of the results of the individual phases should be done in the As we only have three categories (green=OK, red=failed, gray=skip, which in fact comprises all other) we need some convention about how do classify tests with differing outcomes per phase. My proposal is the following (s/t error = error in setup and/or teardown):
The only controvertial question, I guess, is about xfailed and xpassed tests (see also #47).
@jitseniesen: if you're OK with this approach and with the table I'm going to prepare a PR. |
Further to the previous comment: So it boils down to the following: the status column of the widget shows the outcome of the test itself (the call phase), whereas the color indicates if I'll have to care about it. BTW, what is the reason for changing the status names from spyder-unittest/spyder_unittest/backend/pytestrunner.py Lines 136 to 141 in f88518b
I'd rather stick to the traditional names passed and failed as used by pytest (unittests and nosetests report the overall result as either OK or FAILED ).
|
Steffen, thanks for taking the time to write down your analysis. That all makes sense to me, so please go ahead and implement. Do the colours of xpassed/xfailed as you said.
I agree, only processing that all the test frameworks have in common should be done in the datatree widget. I don't know how unittest and pytest handle setup/teardown, but for the moment it makes sense to do as much as possible in the pytestworker.
I am not sure I understand this. Do you mean that if a test passes but the teardown errors, the status will be ok and the colour red? That may be confusing for the user. Or will the message column show some explanation?
I don't remember. I think it is to be consistent with what it was before. I agree with changing those status names to 'passed' and 'failed' as you suggest. What happens if a fixture with module scope errors in the tear down phase? I assume that the last test in the module will get a tear down error? |
That's fine, I don't have a better idea, Perhaps in the future we can think about reporting tear down failures separately, but not now. |
Instead of writing events for each phase (setup, call, teardown) of a test (and eventually displaying them in the datatree widget) we now accumulate results over the individual test phases and only then write the final result of the entire test upon test completion using the pytest_runtest_logfinish hook. This ensures the following: 1) Capturing of output from the teardown phase even if it passes without an error. This fixes spyder-ide#127. 2) Differentiating between the outcome of the test itself (the call phase) and the entire test as a whole. An error during teardown, for instance, used to overwrite the (potentially passed) test result of the call phase. Now we get a passed test with an error during teardown. So in the datatree widget, the test status (first column) is no longer 1:1 linked with the color of this line (see also 3)). 3) Better handling of xfailed and xpassed tests which now show the correct status `xfailed` or `xpassed` and are colored green and red respectively (instead of status `skipped` and gray color for both of them). This fixes spyder-ide#47. 4) Better messages: the first message, which is usually the most important one, will be placed in the message column of the datatree widget. Further messages will be _appended_ to the extra_text field (instead of overwriting messages from previous test phases). If the first message spans over multiple lines then only its first line will be displayed in the message column and the complete message will be repeated in the extra_text field for better readability. This improves the visual impression of the datatree widget so that each (collapsed) row is exactly one line high.
Just installed spyder unittest plugin. When writing and testing a simple xunit style test, the teardown function's output did not get captured.
Simple xunit stype test:
First "Setting up test1!", next "Executing test1!" and finally "Tearing down test1!" should get displayed in that order. Instead, I only see "Setting up test1!" and "Executing test1!" getting displayed.
The output from teardown function does not appear.
The text was updated successfully, but these errors were encountered: