Prevent pytest from running imported functions as tests #11366
-
It seems that pytest is running functions that are imported inside a test file as if they were test functions. My directory structure:
So my question: is there a way to prevent pytest from "collecting"
The problems with
Are there other ways to prevent imported (outside of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not really - there is no good way for pytest to know where something is defined from (short of maybe checking You'll either need to rename it, do a |
Beta Was this translation helpful? Give feedback.
Not really - there is no good way for pytest to know where something is defined from (short of maybe checking
.__module__
, but that is its own can of worms).You'll either need to rename it, do a
from mod import test_stuff as other_name
, or set__test__ = False
on it (not sure if that works on functions though).