On 02/10/2012 19:06, Demian Brecht wrote:
Am I missing something? Is there something that wasn't answered by my reply
about using mixins?
from unittest import TestCase
class SharedTestMixin(object):
def test_shared(self):
self.assertNotEquals('foo', 'bar')
class TestA(TestCase, SharedTestMixin):
def test_a(self):
self.assertEquals('a', 'a')
class TestB(TestCase, SharedTestMixin):
def test_b(self):
self.assertEquals('b', 'b')
$ nosetests test.py -v
test_a (test.TestA) ... ok
test_shared (test.TestA) ... ok
test_b (test.TestB) ... ok
test_shared (test.TestB) ... ok
----------------------------------------------------------------------
Ran 4 tests in 0.001s
OK
This seems to be a clear answer to the problem that solves the original
requirements without introducing error-prone, non-obvious solutions.
Peter Otten's response is obviously vastly superior to yours, 4 tests in
0.000s compared to your highly inefficient 4 tests in 0.001s :)
--
Cheers.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list