[pytest-dev] excluding marked tests as default behavior

Ofer Nave onave at dyn.com
Tue Apr 16 21:49:48 CEST 2013


I do have a working implementation with the following:

1) Create a marker:

slow = pytest.mark.skipif("'SLOW' not in os.environ")

2) Mark appropriate tests:

@slow
def test_which_is_slow():
     ...

3) Turn on slow tests from command line:

$ SLOW=1 py.test

Not exactly the form factor I was looking for, but it does work.

-ofer

On 04/16/2013 03:39 PM, Ofer Nave wrote:
> I understand I can mark tests with `@pytest.mark.whatever` and run 
> them specifically with `pytest -m whatever`, or run skip them with 
> `pytest -m 'not whatever'`.  But how I can configure pytest in my 
> package such that the default behavior is to skip those tests?
>
> Specifically, I have some tests that are very slow (multiple seconds 
> each).  I want to mark them 'slow', and have the default behavior when 
> running `pytest` be to skip them.  That way they will only run if you 
> explicitly run them with `pytest -m slow`.
>
> Is there a way to configure this in conftest.py?
>
> -ofer
> _______________________________________________
> Pytest-dev mailing list
> Pytest-dev at python.org
> http://mail.python.org/mailman/listinfo/pytest-dev



More information about the Pytest-dev mailing list