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

pytest statuses "expected-fail" and "unexpectedly passing" not yet reflected in Category #47

Closed
bilderbuchi opened this issue Jan 14, 2017 · 8 comments · Fixed by #151
Closed
Assignees
Labels

Comments

@bilderbuchi
Copy link

Hi!

Just to note this (can't currently work on this), the pytest statuses "expected to fail" (XFAIL, shown as an "x" in test results) and "“unexpectedly passing” (XPASS) are not yet available in https://github.com/spyder-ide/spyder-unittest/blob/52af625e6a526c218d3a7930fdd348ab5716c724/spyder_unittest/backend/testrunner.py#L28, and probably should be at some point.
See also http://doc.pytest.org/en/latest/skipping.html?highlight=expected%20fail#skip-and-xfail-dealing-with-tests-that-cannot-succeed

@jitseniesen jitseniesen self-assigned this Jan 16, 2017
@jitseniesen jitseniesen added this to the v0.2 milestone Jan 16, 2017
@jitseniesen jitseniesen modified the milestones: v0.3, v0.2 Jun 29, 2017
@jitseniesen
Copy link
Member

In the meantime, Category.SKIP has been used to not only contain skipped tests but also xpass and xfail tests. So I guess it is enough to rename Category.SKIP to Category.MISC.

@bilderbuchi
Copy link
Author

Can't check because on the phone, but if Category is a flagint enum, it should hopefully be possible to cover both the more specific categories of pytest and frameworks that only offer pass/fail/skip with one logic.

@bilderbuchi
Copy link
Author

...if that's the reason you want to go for category.misc, that is.

@jitseniesen
Copy link
Member

I think I may have misunderstood you. Why do you want Category to reflect xpass and xfail?

The Category is not directly user visible, but it does determine the background colour (currently, green for Category.OK = passing tests, red for Category.FAIL = failing tests, blank for Category.PENDING = pending tests and grey for Category.SKIP = the rest). Do you think that xfail, xpass and skip should all have different colours?

@bilderbuchi
Copy link
Author

Ok, then I misunderstood. If it's primarily about the color scheme, I think xfail and xpass should be green, as they represent the test outcome matches the user's expectations, i.e. the test failed or passed, respectively. I wonder if pytest can colour output, that could also offer indications.

@jitseniesen
Copy link
Member

I understand your reasoning but I'm wondering whether this may actually be more confusing. For the record, if you run py.test with the --verbose switch, then "passed" is coloured green, "failed" is coloured red, and "skipped", "xfail" and "xpass" are all coloured yellow.

I'm going to leave this issue open for the moment.

@jitseniesen jitseniesen removed this from the v0.3 milestone Feb 16, 2018
@StefRe
Copy link
Contributor

StefRe commented Apr 19, 2020

@bilderbuchi :

I think xfail and xpass, should be green as they represent the test outcome matches the user's expectations, i.e. the test failed or passed, respectively.

I'm afraid there is some misunderstanding here: xpass means a test that was expected to fail passed UNexpectedly - so it didn't meet the user's expectation and hence should be red and not green.

@bilderbuchi
Copy link
Author

Ah, sounds reasonable, thanks!

StefRe added a commit to StefRe/spyder-unittest that referenced this issue Apr 27, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants