[ python-Bugs-798274 ] absolute import patch breaks external users of test.regrtest

SourceForge.net noreply at sourceforge.net
Fri Nov 21 15:47:27 EST 2003


Bugs item #798274, was opened at 2003-08-31 17:39
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=798274&group_id=5470

Category: Extension Modules
>Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Nicholas Riley (nriley)
>Assigned to: Nobody/Anonymous (nobody)
Summary: absolute import patch breaks external users of test.regrtest

Initial Comment:
I've built a test system using Python's test.regrtest 
mechanism, and it worked very well under Python 2.2.  In 
Python 2.3, the output looks like this:

test_inttypes
test_inttypes skipped -- No module named test_inttypes
test_string
test_unittest
test_unittest skipped -- No module named test_unittest
[...]

I've tracked the problem down to a change made about a 
year ago.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/
python/dist/src/Lib/test/regrtest.py.diff?r1=1.91&r2=1.92

test.regrtest is finding the modules, but is failing to import 
them because it is prepending 'test.' to the module names, 
in a mistaken assumption that all tests will be in a package 
named test.

As it happened, I had my test modules inside a directory 
named 'test', and I tried making the directory a module and 
futzing with sys.path to get it to work, but now 
test.regrtest can't find the system implementation of 
test.test_support.  I've also now got the problem of 
namespace pollution - the "test_string" above is Python's 
version, not my version with the same name.

So, it appears non-Python users of test.regrtest are broken 
by this change in Python 2.3.  I was pretty careful to make 
sure that I was doing something supported - the docstring 
for test.regrtest.main explicitly refers to non-Python test 
suite users - and ran into some weird cases like test.* not 
being installed on Mac OS X by default, but it worked very 
well otherwise.

One potential solution would be that if 'testdir' is specified, 
test.regrtest.main() does not attempt to prepend 'test.' to 
the module names.  This seems to match pretty well with 
the spirit of the documentation for that method.

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

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-11-21 15:47

Message:
Logged In: YES 
user_id=12800

I'm relinquishing assignment of this issue and moving it to
Python 2.4.

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

Comment By: Nicholas Riley (nriley)
Date: 2003-09-17 18:53

Message:
Logged In: YES 
user_id=34933

Thanks for the helpful response.

Sorry I didn't get around to writing any documentation, but a 
patch is here:

http://sourceforge.net/tracker/index.php?
func=detail&aid=808210&group_id=5470&atid=305470

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

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-09-01 23:54

Message:
Logged In: YES 
user_id=12800

IIRC, this patch was necessary because some tests required
absolute imports and we cannot mix relative and absolute
imports in the test suite.  IMO, regrtest's primary mission
in life is to support Python's test suite and any other use
is secondary (for example, it isn't documented in the
standard library manual).  OTOH, you might think about
contributing a patch that allows regrtest to be used outside
the Python test suite, but doesn't break the absolute import
requirement while in the test suite.  (You might also
consider adding some standard lib documentation to your
patch <wink>).

The other problems you mention are inherent in Python's
import machinery.  If you have two packages named "test" on
your sys.path, Python will not by default search them both
for submodules.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-09-01 12:51

Message:
Logged In: YES 
user_id=80475

Barry, this was your change.
Would you take a look at this bug report?

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

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



More information about the Python-bugs-list mailing list