Skip to content

Change pytest collection logic for quirky test suite setup #8515

Answered by nicoddemus
pmeier asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @pmeier,

After the instantiate_tests() call, test_foo.py contains multiple test cases postfixed with the parameter (TestBarSpam, TestBarHam, ...).

Where are the test cases located? Do you inject them in the module's globals?

Just to make sure, by "test cases" you mean test classes?

Unfortunately, neither TestBar nor test_baz exist after the module is loaded.

Not sure I follow, I thought instantiate_tests would create the classes and inject them in the module. To exemplify, I thought this would hold true:

>>> import test_foo
>>> hasattr(test_foo, "TestBarSpam")
True

Thus, I thought I write a small pytest plugin to achieve this.

By "this" I assume you mean "run the test from the ID…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@pmeier
Comment options

@flyingangel2013
Comment options

@pmeier
Comment options

Comment options

You must be logged in to vote
5 replies
@pmeier
Comment options

@nicoddemus
Comment options

@pmeier
Comment options

@pmeier
Comment options

@nicoddemus
Comment options

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