classification
Title: Failed separate tests in test_importlib
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, brett.cannon, serhiy.storchaka, twouters
Priority: normal Keywords: patch

Created on 2018-06-03 14:12 by serhiy.storchaka, last changed 2018-06-05 19:14 by barry. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7412 merged barry, 2018-06-04 23:50
PR 7434 merged miss-islington, 2018-06-05 16:41
Messages (7)
msg318551 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-03 14:12
$ ./python -m test -v -m test_resource test_importlib
...
======================================================================                                                                                                                                                                       
ERROR: test_is_submodule_resource (test.test_importlib.test_resource.ResourceFromZipsTest)                                                                                                                                                   
----------------------------------------------------------------------                                                                                                                                                                       
Traceback (most recent call last):                                                                                                                                                                                                           
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_resource.py", line 113, in test_is_submodule_resource                                                                                                                           
    submodule = import_module('ziptestdata.subdirectory')                                                                                                                                                                                    
  File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 127, in import_module                                                                                                                                                       
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                                                              
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import                                                                                                                                                                            
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load                                                                                                                                                                          
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked                                                                                                                                                                 
ModuleNotFoundError: No module named 'ziptestdata.subdirectory'                                                                                                                                                                              
                                                                                                                                                                                                                                             
======================================================================                                                                                                                                                                       
ERROR: test_read_submodule_resource_by_name (test.test_importlib.test_resource.ResourceFromZipsTest)                                                                                                                                         
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_resource.py", line 119, in test_read_submodule_resource_by_name
    resources.is_resource('ziptestdata.subdirectory', 'binary.file'))
  File "/home/serhiy/py/cpython/Lib/importlib/resources.py", line 223, in is_resource
    package = _get_package(package)
  File "/home/serhiy/py/cpython/Lib/importlib/resources.py", line 47, in _get_package
    module = import_module(package)
  File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'ziptestdata.subdirectory'

======================================================================
ERROR: test_submodule_contents (test.test_importlib.test_resource.ResourceFromZipsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_resource.py", line 122, in test_submodule_contents
    submodule = import_module('ziptestdata.subdirectory')
  File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'ziptestdata.subdirectory'

======================================================================
ERROR: test_submodule_contents_by_name (test.test_importlib.test_resource.ResourceFromZipsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_resource.py", line 129, in test_submodule_contents_by_name
    set(resources.contents('ziptestdata.subdirectory')),
  File "/home/serhiy/py/cpython/Lib/importlib/resources.py", line 248, in contents
    package = _get_package(package)
  File "/home/serhiy/py/cpython/Lib/importlib/resources.py", line 47, in _get_package
    module = import_module(package)
  File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'ziptestdata.subdirectory'

----------------------------------------------------------------------
msg318578 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-06-03 18:52
Was this on your machine or has this started across CI or buildbots? And was this from a build or installed copy?
msg318581 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-03 19:12
Tests are passed if run the whole test_importlib. They are failed only when run the test_resource subset of them. This means that test_resource tests depend on the global environment changed by other tests. And this also means that some changes of the global environment are leaked from some tests, and may affect also other tests.
msg318583 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-06-03 19:50
I can take a look at this tomorrow.
msg318703 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-06-04 20:55
Looks like a sys.modules leak.  I'm working on a branch.
msg318766 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-06-05 16:40
New changeset ac1ee1badade69d5cd6d8b9112281f121183e7c0 by Barry Warsaw in branch 'master':
bpo-33755: Fix importlib.resources isolation tests (#7412)
https://github.com/python/cpython/commit/ac1ee1badade69d5cd6d8b9112281f121183e7c0
msg318781 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-06-05 19:11
New changeset e135032ffa08ad66caea8205488e037da85d2bf8 by Barry Warsaw (Miss Islington (bot)) in branch '3.7':
bpo-33755: Fix importlib.resources isolation tests (GH-7412) (#7434)
https://github.com/python/cpython/commit/e135032ffa08ad66caea8205488e037da85d2bf8
History
Date User Action Args
2018-06-05 19:14:42barrysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-06-05 19:11:46barrysetmessages: + msg318781
2018-06-05 16:41:57miss-islingtonsetpull_requests: + pull_request7060
2018-06-05 16:40:48barrysetmessages: + msg318766
2018-06-04 23:50:55barrysetkeywords: + patch
stage: patch review
pull_requests: + pull_request7037
2018-06-04 20:55:20barrysetmessages: + msg318703
2018-06-03 19:50:12barrysetassignee: barry
2018-06-03 19:50:02barrysetmessages: + msg318583
2018-06-03 19:12:21serhiy.storchakasetmessages: + msg318581
2018-06-03 18:52:13brett.cannonsetmessages: + msg318578
2018-06-03 18:50:44brett.cannonsetnosy: + barry
2018-06-03 14:12:34serhiy.storchakacreate