Mark test to be run in independent process

Viewed 1251

I'm using pytest. I have a test which involves checking that an import is not made when something happens. This is easy enough to make, but when the test is run in pytest it gets run in the same process as many other tests, which may import that thing beforehand.

Is there some way to mark a test to be run in its own process? Ideally there'd be some kind of decorator like

@pytest.mark.run_in_isolation
def test_import_not_made():
    ....

But I haven't found anything like that.

1 Answers
Related