Replies: 1 comment
-
For more complex things like this, I'd use a fixture that uses @pytest.fixture
def ensure_cpu_freq():
if not (hasattr(psutil, "cpu_freq") and bool(psutil.cpu_freq())):
pytest.skip("cpu_freq not supported") and then possibly @pytest.mark.usefixtures("ensure_cpu_freq")
def test_cpu_freq():
... which will now skip the test if it's not available, and fail the test if there is an exception. Also I'm converting this to a discussion, as I don't think there is anything actionable for pytest here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello.
In psutil tests I have the following idiom:
Assuming this makes sense in the first place, would it make sense to give the ability to schedule a failure occurring at import time, so that it gets reported when the test run has finished? Something like:
For the record, I later switched to:
This at least prints a traceback on exit [1], so I will generally notice, but what would be needed here is an actual failure .
[1] unless I run tests in parallel, in which case the stdout is suppressed
Beta Was this translation helpful? Give feedback.
All reactions