[Patches] [ python-Patches-440292 ] Test cases for pyclbr.py

noreply@sourceforge.net noreply@sourceforge.net
Wed, 01 Aug 2001 09:16:51 -0700


Patches item #440292, was opened at 2001-07-10 22:21
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=440292&group_id=5470

Category: library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Mathewson (nickm)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Test cases for pyclbr.py

Initial Comment:
These test cases exercise the pyclbr module.   They
work by comparing the output of pyclbr to the results
of module introspection for some of the largest modules
in the Python distribution.

They also skirt several limitations of pyclbr not
mentioned in the BUGS section of pyclbr.py.  For
example, pyclbr.py does really
bad in the presence of the string [ '"""'  ].   (This
keeps it from handling pydoc.py.)

While writing these test cases, I also found a minor
bug in pyclbr.py that would prevent it from finding
functions (but not classes) declared in other modules. 
I'm also including a patch for this bug.

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

>Comment By: Nick Mathewson (nickm)
Date: 2001-08-01 09:16

Message:
Logged In: YES 
user_id=499

Are you certain you tried the latest version of the test and
the patch?  I just tried the following (on a clean CVS tree):

1) Install test_pyclbr.py. (v3 given below; 153 lines)
2) ./python Lib/test/test_pyclbr.py
GOT ERROR MESSAGE:

test_easy (__main__.PyclbrTest) ... ok
test_others (__main__.PyclbrTest) ... *** getstatus
FAIL

======================================================================
FAIL: test_others (__main__.PyclbrTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_pyclbr.py", line 147, in test_others
    module=sys.modules[__name__])
  File "Lib/test/test_pyclbr.py", line 99, in checkModule
    self.assertHaskey(dict, name, ignore)
  File "Lib/test/test_pyclbr.py", line 43, in assertHaskey
    self.failUnless(obj.has_key(key))
  File "/home/nickm/src/python/dist/src/Lib/unittest.py",
line 249, in failUnless
    if not expr: raise self.failureException, msg
AssertionError

3) Patch pyclbr.py (patch v2 given below; 60 lines)
4) ./python Lib/test/test_pyclbr.py
    [ TESTS PASS ]

Is it possible that you weren't running the most recent
versions of each?  Or do we have platform differences?



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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-22 19:45

Message:
Logged In: YES 
user_id=3066

Sorry -- the new test still doesn't fail without the patch, so there's appearantly something missing in the test.  The patch will definately make more sense if there's an example of what breaks without it.



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

Comment By: Nick Mathewson (nickm)
Date: 2001-07-21 20:10

Message:
Logged In: YES 
user_id=499

Well, there were two problems:

1) The test case didn't test the problem I thought it did.

2) The patch didn't fix the problem I thought I was testing! :)

I'm uploading new versions of each.

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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-21 13:38

Message:
Logged In: YES 
user_id=3066

The test case doesn't cover the bug fixed in the patch; it should fail if I try it without applying the patch.

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

Comment By: Nick Mathewson (nickm)
Date: 2001-07-19 17:25

Message:
Logged In: YES 
user_id=499

Updated to use unittest, and to be generally a bit more legible.

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

Comment By: Nick Mathewson (nickm)
Date: 2001-07-10 22:22

Message:
Logged In: YES 
user_id=499

(More information on the bug: whereas pyclbr.py can notice
imports
of the format: "from module import class", it wasn't able to
handle "from module import fn".  Now it can.)

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

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