Reputation: 27311
I'm adding some performance smoke tests to our test suite, and they fail spectacularly when running py.test with coverage. This isn't very surprising, nor an indication of a performance issue (timings under coverage don't relate to anything real..)
How do I mark (ie. pytest.mark.skipif(..)
) these tests so they're automatically skipped during coverage runs?
I'm using PyCharm during development if it is relevant.
Upvotes: 2
Views: 1271
Reputation: 5285
That should be quite doable, using the pytest config
object. See the very last example on Skip and xfail:
@pytest.mark.skipif(not pytest.config.getvalue("db"),
reason="--db was not specified")
def test_function(...):
pass
I imagine what you want is just
@pytest.mark.skipif(pytest.config.getvalue("--cov"),
reason="--cov not compatible with smoke tests")
(ETA: The destination of cov
is actually cov_source
, which is why it didn't recognise cov
. Putting --cov
seems like a safer bet as it matches the option you actually type and doesn't require you to know the code internals.)
Upvotes: 1