pytest.skip will skip entire files when used as a decorator #607
Comments
Original comment by Kiril Vladimiroff (BitBucket: Vladimiroff, GitHub: Vladimiroff): If there is going to be a check like this why not simply do |
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): From a API design perspective I dislike mixing pytest.mark.skipif and pytest.skip because it mixes a "declarative" (mark it as being skipped) and an "imperative" (skip it now) way of doing things. Bailing out with a clear error, pointing to use "mark.skipif" allows to keep the conceptual separation which is better in the long run IMO. |
Original comment by Kiril Vladimiroff (BitBucket: Vladimiroff, GitHub: Vladimiroff): Fair point, but from usage perspective I find it awkward to do |
Original comment by Bryce Lampe (BitBucket: blampe, GitHub: blampe):
I don't think there is any such conceptual separation for users of the API, though. This is largely because
In fact, writing |
Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff): I agree with Holger on that it's bad idea to mix conceptions |
Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub): I think the case is made that the So with that in mind I am also in favour of detecting If that is still too confusing the I'd suggest that py.test should drop the |
Original comment by Kiril Vladimiroff (BitBucket: Vladimiroff, GitHub: Vladimiroff): @flub, great then my pull request suits fine until the |
FWIW the implementation for |
@nicoddemus @hpk should we issue a pytest_warning if pytest.skip happens outside of the runtestprotocol? |
Sounds good, but as we commented before, the current warnings system could use some improvements. |
Originally reported by: Bryce Lampe (BitBucket: blampe, GitHub: blampe)
I've seen several people assume that
@pytest.skip
can be used in place of@pytest.mark.skipif(True, reason="foo")
. It seems like a reasonable convenience and it seems to work. However, this is actually quite dangerous because it has the unexpected side-effect of skipping every test in the file:Expected behavior:
Actual behavior:
Note that this is reporting the wrong number of skipped tests, so this definitely seems unintentional.
The text was updated successfully, but these errors were encountered: