This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Test cases for pyclbr.py
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, nickm
Priority: normal Keywords: patch

Created on 2001-07-11 05:21 by nickm, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_pyclbr.py nickm, 2001-07-11 05:21 Test cases for pyclbr.py (v1)
pyclbr.diff nickm, 2001-07-11 05:22 Change pyclbr.readmodule_ex to recurse properly.
/home/nickm/src/patches/test_pyclbr.py nickm, 2001-07-20 00:25 Test case for pyclbr.py (v2)
/home/nickm/src/patches/test_pyclbr.py nickm, 2001-07-22 03:10 Test cases for pyclbr.py (v3)
/home/nickm/src/patches/pyclbr.diff nickm, 2001-07-22 03:11 Change pyclbr.readmodule_ex to recurse properly... everywhere. (v2)
Messages (8)
msg36949 - (view) Author: Nick Mathewson (nickm) Date: 2001-07-11 05:21
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.
msg36950 - (view) Author: Nick Mathewson (nickm) Date: 2001-07-11 05:22
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.)
msg36951 - (view) Author: Nick Mathewson (nickm) Date: 2001-07-20 00:25
Logged In: YES 
user_id=499

Updated to use unittest, and to be generally a bit more legible.
msg36952 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-07-21 20:38
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.
msg36953 - (view) Author: Nick Mathewson (nickm) Date: 2001-07-22 03:10
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.
msg36954 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-07-23 02:45
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.

msg36955 - (view) Author: Nick Mathewson (nickm) Date: 2001-08-01 16:16
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?

msg36956 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-08-13 20:26
Logged In: YES 
user_id=3066

OK, I musta had some bad soda that day... ;-)  This is now checked in as Lib/pyclbr.py revision 1.22; the test code has also been added.

Thanks!
History
Date User Action Args
2022-04-10 16:04:11adminsetgithub: 34730
2001-07-11 05:21:08nickmcreate