[TIP] Reusable test suites in nose

Dan Wandschneider daniel.wandschneider at schrodinger.com
Mon Jan 7 13:44:58 PST 2013


You could also create a TestCase inheritance structure like this:

class TestCaseGeneric(TestCase)
    "provide virtual methods for interacting with the interface."
class TestCaseInterface1(TestCaseVirtual)
    "provide real methods for interacting with the interface, and real
tests."
class TestCaseInterface2(TestCaseInterface1)
    "provide real methods for interacting with the interface, uses tests
from TestCaseInterface1."

This would achieve the same result as use of your @onlyinsubclass
decorator.  Granted, this breaks the SRP (
http://en.wikipedia.org/wiki/Single_responsibility_principle), but it
removes the dependence of your test on an outside module, which is a Good
Thing.

-Dan W.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130107/a3ef8c5b/attachment.htm>


More information about the testing-in-python mailing list