[Python-Dev] Adding test case methods to TestCase subclasses (was: python and super)
Ben Finney
ben+python at benfinney.id.au
Fri Apr 15 01:19:36 CEST 2011
Ethan Furman <ethan at stoneleaf.us> writes:
> Here we have django's TestCase that does *not* want to call
> unittest2.TestCase (assuming that's not a bug), but it gets called
> anyway because the Mixin3 sibling has it as a base class. So does
> this mean that TestCase and Mixin3 just don't play well together?
>
> Maybe composition instead of inheritance is the answer (in this case,
> anyway ;).
TestCase subclasses is a multiple-inheritance use case that I share. The
mix-ins add test cases (methods named ‘test_’ on the mix-in class) to
the TestCase subclass. I would prefer not to use multiple inheritance
for this if it can be achieved in a better way.
How can composition add test cases detectable by Python 2's ‘unittest’
and Python 3's ‘unittest2’?
--
\ “The userbase for strong cryptography declines by half with |
`\ every additional keystroke or mouseclick required to make it |
_o__) work.” —Carl Ellison |
Ben Finney
More information about the Python-Dev
mailing list