Replies: 1 comment
-
pytest currently has no utilities/patterns to inherit/reconfigure partial testsuites so currently anything you want to ship with your lib to enable plugin/extension implementers to build those things is currently to be selfmade some people use inheritance/mixins to work around that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm the co-maintainer of a library providing a few types which wrap duck types. To make the adoption easier I would like to provide a function which generates a test suite to check their compatibility with my library.
I came up with something like this:
where
marks
can be used to skip / xfail specific tests / test items.However, attaching marks to specific test items seems to require a
pytest_collection_modifyitems
hook, which would require me to write and distribute a plugin if I want to usegenerate_tests
in other projects. Additionally, since the creation and possibly the test itself might need more parameters depending on the duck type I would either need to figure out a way to dynamically add more parameters, or switch to using fixtures and theirparams
kwarg instead of creation functions.I did consider using subclasses and
staticmethod
s for the callbacks (create
, etc), but rejected this because theparametrize
marks get stripped for subclasses (I think there was a issue for that but I can't find it right now).All of this makes me wonder if I'm missing something obvious. Are there any established patterns or libraries which handle this sort of testing? If not, is there a way to make this a bit easier to maintain?
Beta Was this translation helpful? Give feedback.
All reactions