[TIP] [ANN] simppu.py -- Simply Python Unit Testing

Pekka Klärck peke at iki.fi
Wed Mar 17 01:44:03 PDT 2010


>> On Tue, Mar 16, 2010 at 9:47 PM, Pekka Klärck <peke at iki.fi> wrote:
>>>
>>> After few hours hacking, and 132 lines of Python, I have a pretty
>>> promising prototype that:
>>> - requires zero boilerplate (any function or method starting with
>>> 'test_' in a file starting with 'test_' is a test),

> On Tue, Mar 16, 2010 at 10:00 PM, Alfredo Deza <alfredodeza at gmail.com> wrote:
>> This will effectively break (or will not work) with (after browsing your
>> source code):
>> Test_
>> TEST_
>> Or any other combination of upper + lower case in test.
>> Your test discovery should be able to resolve case insensitive naming... I
>> think.

Although I don't see why you would like to have files or
functions/methods with these names, case-insensitively would be
trivial to add. It might also be a good idea to recognize methods
named like 'testSomething' for backwards compatibility, and to enable
configuring the pattern to find files containing tests. In general the
conventions must be pretty strict, though, because the whole idea is
to rely on them instead of configuration.

2010/3/17 Mark Roddy <markroddy at gmail.com>:
> Or you might want to concentrate on a tool for test authoring and
> leverage another package for test discovery (though you might need to
> write some extensions to it):
> http://pypi.python.org/pypi/discover/0.3.2

This seems to be the module that does test discovery in unittest2. I
don't see why I should use it for something that it isn't designed
for, especially when I can use Python's strong introspection
capabilities to find test methods myself. See the example below for
what kind of tests I want to write.

def test_as_function():
    assert something

class NoNeedToExtendAnything:
    def setup(self):
        self.x = 42
    def test_as_method(self):
        if something != self.x:
            raise AssertionError('...')


Cheers,
    .peke
-- 
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org



More information about the testing-in-python mailing list