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_importlib failures under Windows
Type: behavior Stage: needs patch
Components: Library (Lib), Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, pitrou, python-dev, vstinner
Priority: normal Keywords:

Created on 2012-01-27 16:50 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (8)
msg152102 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-27 16:50
I don't know if these are related to the latest changes, but they only appear on the 3.3 buildbots:

======================================================================
FAIL: test_case_insensitivity (importlib.test.extension.test_case_sensitivity.ExtensionModuleCaseSensitivityTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\importlib\test\extension\test_case_sensitivity.py", line 30, in test_case_insensitivity
    self.assertTrue(hasattr(loader, 'load_module'))
AssertionError: False is not true

======================================================================
FAIL: test_insensitive (importlib.test.source.test_case_sensitivity.CaseSensitivityTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\importlib\test\source\test_case_sensitivity.py", line 51, in test_insensitive
    self.assertTrue(hasattr(insensitive, 'load_module'))
AssertionError: False is not true
msg152121 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-01-27 21:28
I was getting that error the other day on my OS X laptop, but then I thought I tweaked the code well enough to solve it (since I am running on a case-insensitive filesystem as well). It seems to stem from what nt.environ contains when the test sets PYTHONCASEOK and importlib._bootstrap._case_ok() tries to see if b'PYTHONCASEOK' is in nt.environ.

You (or anyone) have a Windows box to quickly test what nt.environ contains after os.environ.set('PYTHONCASEOK', '1') is called?
msg152123 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-01-27 21:36
Otherwise it's the nt.listdir() comparison that's failing. Probably should check that is returning reasonable stuff as well.
msg152126 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-27 21:42
Well apparently nt.environ doesn't reflect os.environ:

>>> os.environ['PYTHONCASEOK'] = '1'
>>> nt.environ['PYTHONCASEOK']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'PYTHONCASEOK'
>>> nt.environ[b'PYTHONCASEOK']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: b'PYTHONCASEOK'
>>> os.environ['PYTHONCASEOK']
'1'
>>> os.environ[b'PYTHONCASEOK']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\t\cpython\lib\os.py", line 450, in __getitem__
    value = self._data[self.encodekey(key)]
  File "C:\t\cpython\lib\os.py", line 508, in encodekey
    return encode(key).upper()
  File "C:\t\cpython\lib\os.py", line 503, in check_str
    raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bytes

This is silly and is because of how the environ mapping is implemented in Lib/os.py: under POXIX, os.environ reflects posix.environ (it uses the same underlying dict), while under Windows, os.environ uses a distinct dict from nt.environ.
msg152249 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-01-29 17:48
Is there a technological reason environ is not updated, or is it simply
oversight?

Lib/os.py: under POXIX, os.environ reflects posix.environ (it uses the same
underlying dict), while under Windows, os.environ uses a distinct dict from
nt.environ.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue13890>
> _______________________________________
>
msg152251 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-29 17:52
I think it's more laziness. _Environ.__setitem__ could also update the original mapping.
msg152338 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-30 17:49
New changeset 54d7823ec488 by Brett Cannon in branch 'default':
Issue #13890: Fix importlib case-sensitivity tests to not run on Windows.
http://hg.python.org/cpython/rev/54d7823ec488
msg152339 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-30 17:51
New changeset 2914ce82bf89 by Brett Cannon in branch 'default':
Issue #13890: Also fix for extension module tests for case-insensitivity.
http://hg.python.org/cpython/rev/2914ce82bf89
History
Date User Action Args
2022-04-11 14:57:26adminsetgithub: 58098
2012-01-30 17:52:15brett.cannonsetstatus: open -> closed
resolution: fixed
2012-01-30 17:51:58python-devsetmessages: + msg152339
2012-01-30 17:49:44python-devsetnosy: + python-dev
messages: + msg152338
2012-01-29 17:52:54pitrousetnosy: + vstinner
messages: + msg152251
2012-01-29 17:48:24brett.cannonsetmessages: + msg152249
2012-01-27 21:42:47pitrousetmessages: + msg152126
2012-01-27 21:36:22brett.cannonsetmessages: + msg152123
2012-01-27 21:28:47brett.cannonsetmessages: + msg152121
2012-01-27 16:50:56pitroucreate