Pytest\'s default discovery rules will import all Class starting with Test
that do not have an __init__()
. I have a situation where this causes an
The configuration options seem to only be prefixes or globs, so I don't think you can exclude a specific file name: https://pytest.org/latest/customize.html#confval-python_classes
I think renaming your class (MyTestimonialFactory) or moving it outside of the discovery path would be the easy fix here.
That said, I still think you could use one of the collection hooks to skip or remove that class during collection. Perhaps pytest_pycollect_makeitem
, as described here:
https://docs.pytest.org/en/latest/writing_plugins.html#collection-hooks