Skip to content

Prevent pytest from running imported functions as tests #11366

Answered by The-Compiler
nielsbuwen asked this question in Q&A
Discussion options

You must be logged in to vote

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).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nielsbuwen
Comment options

Answer selected by nielsbuwen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants