-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
__test__ = ...
abstract helper
#12780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah I have the same sentiments against it:
However perhaps adding a link to an external project which implements this? Or perhaps as you said, doing nothing is also a possibility. |
yeah I'm ok saying "declined" :) |
I'm curious (in relation to #12726) whether the |
it probably could be an |
What's the problem this feature will solve?
it's fairly error prone to remember to set
__test__ = True
in subclasses of "abstract" tests which are marked with__test__ = False
(to prevent execution)Describe the solution you'd like
instead I've written a small helper that assists with this -- and perhaps it could have a home in pytest? though putting on my pytest maintainer hat I would be hesitant to add this as it seems to encourage inheritance-based testing (which I personally actively discourage!)
the usage is fairly simple:
it then uses descriptor magic to make that
False
in the base class only andTrue
after inheritedAlternative Solutions
in a previous framework I maintained (testify) the lookup of
__test__
was only done ascls.__dict__.get('__test__', True)
such that subclasses were automatically enabled instead of needing to explicitly override as__test__ = True
-- I think this is probably too disruptive of a change to implement here in pytestor really the other reasonable alternative is do nothing -- I don't think this is that dire of a problem that it needs a feature
Additional context
#8612 -- ironically I also rejected this similar idea, this one uses a mixin instead of descriptor magic. the same criticisim there also applies here (what if you have multiple layers of abstract tests?)
The text was updated successfully, but these errors were encountered: