Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absolute import patch breaks external users of test.regrtest #39162

Closed
nicholasriley mannequin opened this issue Aug 31, 2003 · 6 comments
Closed

absolute import patch breaks external users of test.regrtest #39162

nicholasriley mannequin opened this issue Aug 31, 2003 · 6 comments
Labels
extension-modules C modules in the Modules dir

Comments

@nicholasriley
Copy link
Mannequin

nicholasriley mannequin commented Aug 31, 2003

BPO 798274
Nosy @warsaw, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-03-12.01:10:34.000>
created_at = <Date 2003-08-31.21:39:13.000>
labels = ['extension-modules']
title = 'absolute import patch breaks external users of test.regrtest'
updated_at = <Date 2007-03-12.01:10:34.000>
user = 'https://bugs.python.org/nicholasriley'

bugs.python.org fields:

activity = <Date 2007-03-12.01:10:34.000>
actor = 'collinwinter'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Extension Modules']
creation = <Date 2003-08-31.21:39:13.000>
creator = 'nicholas.riley'
dependencies = []
files = []
hgrepos = []
issue_num = 798274
keywords = []
message_count = 6.0
messages = ['18030', '18031', '18032', '18033', '18034', '18035']
nosy_count = 4.0
nosy_names = ['barry', 'collinwinter', 'rhettinger', 'nicholas.riley']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue798274'
versions = ['Python 2.4']

@nicholasriley
Copy link
Mannequin Author

nicholasriley mannequin commented Aug 31, 2003

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.

@nicholasriley nicholasriley mannequin closed this as completed Aug 31, 2003
@nicholasriley nicholasriley mannequin added the extension-modules C modules in the Modules dir label Aug 31, 2003
@nicholasriley nicholasriley mannequin closed this as completed Aug 31, 2003
@nicholasriley nicholasriley mannequin added the extension-modules C modules in the Modules dir label Aug 31, 2003
@rhettinger
Copy link
Contributor

Logged In: YES
user_id=80475

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

@warsaw
Copy link
Member

warsaw commented Sep 2, 2003

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.

@nicholasriley
Copy link
Mannequin Author

nicholasriley mannequin commented Sep 17, 2003

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

@warsaw
Copy link
Member

warsaw commented Nov 21, 2003

Logged In: YES
user_id=12800

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

@collinwinter
Copy link
Mannequin

collinwinter mannequin commented Mar 12, 2007

regrtest's purpose is to test Python; third-party projects wishing to use regrtest in their own test suites would do well to customize it for their particular needs.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir
Projects
None yet
Development

No branches or pull requests

2 participants