classification
Title: Make test_importlib run tests under both _frozen_importlib and importlib._bootstrap
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, eric.snow, ezio.melotti, meador.inge, python-dev
Priority: normal Keywords:

Created on 2012-12-28 18:07 by brett.cannon, last changed 2013-11-08 21:37 by eric.snow. This issue is now closed.

Messages (17)
msg178409 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-12-28 18:07
Need to do some work on the importlib tests such that they get run using both _frozen_importlib and importlib._bootstrap to prevent any drift between importlib/_bootstrap.py and import.c (and to make it easier to develop).
msg179057 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-01-04 17:51
Is the usual PEP 399 idiom enough, or is something more advanced required?
msg179060 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-01-04 18:09
With some tricky use of import_fresh_module() because importlib.__init__ does some masking trickery, it should ... I think. =)
msg198953 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-10-04 14:15
It looks like as long as you block _frozen_importlib and do a fresh import of importlib you can make sure to use the source version of importlib._bootstrap instead of _frozen_importlib.


>>> from test.support import import_fresh_module
>>> mod = import_fresh_module('importlib.abc', fresh=('importlib',), blocked=('_frozen_importlib',))
>>> mod
<module 'importlib.abc' from '/Users/bcannon/Repositories/cpython/default/Lib/importlib/abc.py'>
>>> mod._bootstrap
<module 'importlib._bootstrap' from '/Users/bcannon/Repositories/cpython/default/Lib/importlib/_bootstrap.py'>
>>> mod._frozen_importlib
>>> import importlib
>>> importlib._bootstrap
<module 'importlib._bootstrap' (frozen)>
>>> mod2 = import_fresh_module('importlib', blocked=('_frozen_importlib',))
>>> mod2
<module 'importlib' from '/Users/bcannon/Repositories/cpython/default/Lib/importlib/__init__.py'>
>>> mod2._bootstrap
<module 'importlib._bootstrap' from '/Users/bcannon/Repositories/cpython/default/Lib/importlib/_bootstrap.py'>
msg198958 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-10-04 16:14
Turns out this isn't as clean-cut as simply using test.support.import_fresh_module() as you end up with different instances of importlib._bootstrap which kills any possible subclass checks, etc. between e.g. importlib.abc and importlib.machinery as the source versions will have different instances of importlib._bootstrap.
msg198960 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-04 18:47
New changeset f0416b2b5654 by Brett Cannon in branch 'default':
Issue #16803: Run test.test_importlib.test_abc under both
http://hg.python.org/cpython/rev/f0416b2b5654
msg200266 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-18 14:46
New changeset 9d96a3163dbf by Brett Cannon in branch 'default':
Issue #16803: test.test_importlib.test_api now runs under frozen and
http://hg.python.org/cpython/rev/9d96a3163dbf
msg200299 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-18 19:12
New changeset 66e219519279 by Brett Cannon in branch 'default':
Issue #16803: Have test_importlib.test_locks use frozen and source
http://hg.python.org/cpython/rev/66e219519279
msg200301 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-18 19:40
New changeset 862043d74fae by Brett Cannon in branch 'default':
Issue #16803: Move test_importlib.test_util to use both frozen and
http://hg.python.org/cpython/rev/862043d74fae
msg201252 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-25 16:34
New changeset becc0a488189 by Brett Cannon in branch 'default':
Issue #16803: Stop having test.test_importlib.abc ABCs inherit from
http://hg.python.org/cpython/rev/becc0a488189
msg201257 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-25 16:44
New changeset e2c3f638c3d0 by Brett Cannon in branch 'default':
Issue #16803: Have test.test_importlib.builtin test both frozen and
http://hg.python.org/cpython/rev/e2c3f638c3d0
msg201281 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-25 19:39
New changeset f3d50720dee0 by Brett Cannon in branch 'default':
Issue #16803: Move test.test_importlib.extension to use both frozen and source importlib code
http://hg.python.org/cpython/rev/f3d50720dee0
msg202432 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-08 16:10
New changeset b26e6e3e8037 by Brett Cannon in branch 'default':
Issue #16803: test.test_importlib.frozen now runs both frozen and source code
http://hg.python.org/cpython/rev/b26e6e3e8037
msg202440 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-08 18:35
New changeset 6c998d72553a by Brett Cannon in branch 'default':
Issue #16803: test.test_importlib.import_ now tests frozen and source code
http://hg.python.org/cpython/rev/6c998d72553a
msg202442 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-08 19:25
New changeset b0f570aef6fd by Brett Cannon in branch 'default':
Issue #16803: test.test_importlib.source now tests frozen and source code
http://hg.python.org/cpython/rev/b0f570aef6fd
msg202443 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-11-08 19:29
test_importlib now runs both frozen and source code for all relevant tests. Should allow for making changes in the source w/o recompiling and making sure any source tests pass. Also makes sure the pure Python implementation of import that mirrors what import.c does stays compatible.
msg202447 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-11-08 21:37
Hurray!
History
Date User Action Args
2013-11-08 21:37:02eric.snowsetmessages: + msg202447
2013-11-08 19:29:26brett.cannonsetstatus: open -> closed
title: Make test_import & test_importlib run tests under both _frozen_importlib and importlib._bootstrap -> Make test_importlib run tests under both _frozen_importlib and importlib._bootstrap
messages: + msg202443

resolution: fixed
stage: needs patch -> resolved
2013-11-08 19:25:46python-devsetmessages: + msg202442
2013-11-08 18:35:07python-devsetmessages: + msg202440
2013-11-08 16:10:48python-devsetmessages: + msg202432
2013-10-25 19:39:10python-devsetmessages: + msg201281
2013-10-25 16:44:43python-devsetmessages: + msg201257
2013-10-25 16:34:29python-devsetmessages: + msg201252
2013-10-18 19:40:39python-devsetmessages: + msg200301
2013-10-18 19:12:49python-devsetmessages: + msg200299
2013-10-18 14:46:27python-devsetmessages: + msg200266
2013-10-04 18:47:27python-devsetnosy: + python-dev
messages: + msg198960
2013-10-04 16:14:10brett.cannonsetmessages: + msg198958
2013-10-04 14:15:54brett.cannonsettitle: Make test_importlib run tests under both _frozen_importlib and importlib._bootstrap -> Make test_import & test_importlib run tests under both _frozen_importlib and importlib._bootstrap
2013-10-04 14:15:30brett.cannonsetmessages: + msg198953
2013-06-22 00:43:40brett.cannonsetassignee: brett.cannon
2013-01-24 07:24:14eric.snowsetnosy: + eric.snow
2013-01-04 18:09:27brett.cannonsetmessages: + msg179060
2013-01-04 17:51:28ezio.melottisetnosy: + ezio.melotti
messages: + msg179057
2012-12-31 13:45:40brett.cannonsettitle: Make time_importlib run tests under both _frozen_importlib and importlib._bootstrap -> Make test_importlib run tests under both _frozen_importlib and importlib._bootstrap
2012-12-29 02:37:58meador.ingesetnosy: + meador.inge
2012-12-28 18:07:49brett.cannoncreate