On 10/3/2012 5:33 AM, Oscar Benjamin wrote:
On 3 October 2012 02:20, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
But surely, regardless of where that functionality is defined, you still
need to test that both D1 and D2 exhibit the correct behaviour? Otherwise
D2 (say) may break
On 3 October 2012 02:20, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
But surely, regardless of where that functionality is defined, you still
need to test that both D1 and D2 exhibit the correct behaviour? Otherwise
D2 (say) may break that functionality and your tests won't
Greetings!
I'm trying to unittest a class hierachy using Python 2.7. I have a
common baseclass Base and derived classes D1 and D2 that I want to test.
The baseclass in not instantiatable on its own. Now, the first approach
is to have test cases TestD1 and TestD2, both derived from class
[1] in C++ I would call that a mixin
Mixins are perfectly valid Python constructs as well and are perfectly
valid (imho) for this use case.
On a side note, I usually append a Mixin suffix to my mixin classes in
order to make it obvious to the reader.
--
Demian Brecht
@demianbrecht
On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote:
As you see, the code for test_base() is redundant, so the idea is to
move it to a baseclass:
class TestBase(unittest.TestCase):
def test_base(self):
...
class TestD1(TestBase):
def test_r(self):
Ulrich Eckhardt wrote:
As you see, the code for test_base() is redundant, so the idea is to
move it to a baseclass:
class TestBase(unittest.TestCase):
def test_base(self):
...
class TestD1(TestBase):
def test_r(self):
...
def test_s(self):
Peter Otten wrote:
Ulrich Eckhardt wrote:
The problem here is that TestBase is not a complete test case (just
as
class Base is not complete), but the unittest framework will still
try
to run it on its own.
How exactly are you invoking the test runner? unittest? nose? You can
tell the test
Am 02.10.2012 16:06, schrieb Thomas Bach:
On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote:
As you see, the code for test_base() is redundant, so the idea is to
move it to a baseclass:
class TestBase(unittest.TestCase):
def test_base(self):
...
class
Am 02.10.2012 16:06, schrieb Thomas Bach:
On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote:
As you see, the code for test_base() is redundant, so the idea is to
move it to a baseclass:
class TestBase(unittest.TestCase):
def test_base(self):
...
class
Ulrich Eckhardt wrote:
Am 02.10.2012 16:06, schrieb Thomas Bach:
On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote:
As you see, the code for test_base() is redundant, so the idea is to
move it to a baseclass:
class TestBase(unittest.TestCase):
def test_base(self):
Fayaz Yusuf Khan wrote:
Peter Otten wrote:
Ulrich Eckhardt wrote:
The problem here is that TestBase is not a complete test case (just
as
class Base is not complete), but the unittest framework will still
try
to run it on its own.
How exactly are you invoking the test runner? unittest?
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):
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):
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,
Ulrich Eckhardt ulrich.eckha...@dominolaser.com writes:
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.
It sounds, from your description so far, that you have identified a
design flaw in D1 and D2.
The common
In article mailman.1734.1349199947.27098.python-l...@python.org,
Peter Otten __pete...@web.de wrote:
Another is to remove it from the global namespace with
del TestBase
When I had this problem, that's the solution I used.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 03 Oct 2012 08:30:19 +1000, Ben Finney wrote:
Ulrich Eckhardt ulrich.eckha...@dominolaser.com writes:
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.
It sounds, from your description so far, that
17 matches
Mail list logo