<div class="gmail_quote"><div>Am I missing something? Is there something that wasn't answered by my reply about using mixins?</div><div><br></div><div><div>from unittest import TestCase</div><div><br></div><div>class SharedTestMixin(object):</div>
<div>    def test_shared(self):</div><div>        self.assertNotEquals('foo', 'bar')</div><div><br></div><div>class TestA(TestCase, SharedTestMixin):</div><div>    def test_a(self):</div><div>        self.assertEquals('a', 'a')</div>
<div><br></div><div>class TestB(TestCase, SharedTestMixin):</div><div>    def test_b(self):</div><div>        self.assertEquals('b', 'b')</div></div><div><br></div><div><div>$ nosetests test.py -v</div><div>
test_a (test.TestA) ... ok</div><div>test_shared (test.TestA) ... ok</div><div>test_b (test.TestB) ... ok</div><div>test_shared (test.TestB) ... ok</div><div><br></div><div>----------------------------------------------------------------------</div>
<div>Ran 4 tests in 0.001s</div><div><br></div><div>OK</div></div><div><br></div><div>This seems to be a clear answer to the problem that solves the original requirements without introducing error-prone, non-obvious solutions.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"></div></div>
Sorry, there's a misunderstanding: I want test_base() to be run as part of both TestD1 and TestD2, because it tests basic functions provided by both classes D1 and D2. The instances of D1 and D2 are created in TestD1.setUp and TestD2.setUp and then used by all tests. There is no possible implementation creating such an instance for TestBase, since the baseclass is abstract.<br>

<br>
Last edit for today, I hope that makes my intentions clear...<br>
<br>
;)<br>
<br>
Uli<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>