On 10/3/2012 5:33 AM, Oscar Benjamin wrote:
On 3 October 2012 02:20, Steven D'Aprano
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 wo
On 3 October 2012 02:20, Steven D'Aprano
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 notice.
>
> Given a class hierarchy
On Wed, 03 Oct 2012 08:30:19 +1000, Ben Finney wrote:
> Ulrich Eckhardt 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
>
In article ,
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
Ulrich Eckhardt 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 functionality should be moved
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, S
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):
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 runn
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_b
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 TestD1(TestBas
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 TestD1(TestBas
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
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):
>
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):
>
[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
ht
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 TestCa
17 matches
Mail list logo