[Patches] [ python-Patches-662807 ] Port tests to unittest

SourceForge.net noreply@sourceforge.net
Sun, 19 Jan 2003 06:46:35 -0800


Patches item #662807, was opened at 2003-01-05 15:50
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=662807&group_id=5470

Category: Tests
Group: Python 2.3
Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
>Assigned to: Walter Dörwald (doerwalter)
Summary: Port tests to unittest

Initial Comment:
This patch ports the three tests test_pow.py, 
test_charmapcodec.py and test_userdict.py to unittest.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-19 09:46

Message:
Logged In: YES 
user_id=80475

All are approved except test_charmapcodec.py -- 
someone else should look at that one.

Be sure to follow GvR's advice and replace assertEquals 
with assertEqual.

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-16 15:47

Message:
Logged In: YES 
user_id=89016

test_unicode is ported and enhanced (coverage goes from
80.81% to 85.05%)

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-10 12:17

Message:
Logged In: YES 
user_id=89016

> In general, don't do tests that hardwire implementation 
details

So should we remove
self.assertEquals(reduce(42, "1"), "1")
self.assertEquals(reduce(42, "", "1"), "1")
from test_filter?

BTW, you should look at test_builtin first, as the others
are still simply ports to PyUnit.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-10 12:03

Message:
Logged In: YES 
user_id=80475

Good to hear the news on increasing the coverage.

In general, don't do tests that hardwire implementation 
details.  Test it if it is a documented variable,  exposed 
through __all__, is a key constact (like the magic numbers 
in random.py), or a variable that a module user is likely to 
be relying upon.  Otherwise, no -- it should be possible to 
improve an implementation without crashing the suite.

I'll try to review a few of these over the next few days.

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-10 11:53

Message:
Logged In: YES 
user_id=89016

test_builtin.py is now updated to test more error
situations. This increases the coverage of bltinmodule.c
from 75.13% to 92.20%, and it actually revealed one or two
potential bugs:
http://www.python.org/sf/665761 and
http://www.python.org/sf/665835

I'm not 100% sure that test_intern() and test_execfile() do
the right thing.

I'm not sure, whether the test script should check for
undocumented implementation artefacts, like:

a = 1
self.assert_(min(a, 1L) is a)

but in this way at least we get notified if something is
changed unintentionally.


----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-08 14:05

Message:
Logged In: YES 
user_id=89016

test_b1 and test_b2 are combined into test_builtin now

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-08 09:03

Message:
Logged In: YES 
user_id=6380

Two random suggestions:

- a blank line before each method, even trivial ones, even
the first one

- use assertEqual, not assertEquals

BTW, I see you've picked up on the convention that unit test
methods should not have doc strings. Good! (But they may
have comments.)

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-07 11:37

Message:
Logged In: YES 
user_id=89016

test_b1.py has been ported too.

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-01-05 15:56

Message:
Logged In: YES 
user_id=89016

The patch is hard to read, so I'll upload all three test scripts.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=662807&group_id=5470