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: Various test failures if PYTHONUSERBASE is not canonicalized
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: akshaysharma096, iritkatriel, jdemeyer, ned.deily, nitishch
Priority: normal Keywords: easy, patch

Created on 2018-04-04 14:00 by jdemeyer, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 6434 open akshaysharma, 2018-04-09 17:21
Messages (8)
msg314931 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2018-04-04 14:00
Setting PYTHONUSERBASE=/tmp/x/.. causes the Python test suite to fail:

======================================================================
FAIL: test_user_similar (test.test_sysconfig.TestSysConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/src/sage-config/local/src/cpython/Lib/test/test_sysconfig.py", line 276, in test_user_similar
    self.assertEqual(user_path, global_path.replace(base, user, 1))
AssertionError: '/tmp/lib/python3.8' != '/tmp/x/../lib/python3.8'
- /tmp/lib/python3.8
+ /tmp/x/../lib/python3.8
?     +++++

======================================================================
FAIL: test_get_path (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/src/sage-config/local/src/cpython/Lib/test/test_site.py", line 192, in test_get_path
    sysconfig.get_path('purelib', scheme))
AssertionError: '/tmp/x/../lib/python3.8/site-packages' != '/tmp/lib/python3.8/site-packages'
- /tmp/x/../lib/python3.8/site-packages
?     -----
+ /tmp/lib/python3.8/site-packages


======================================================================
FAIL: test_s_option (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/src/sage-config/local/src/cpython/Lib/test/test_site.py", line 199, in test_s_option
    self.assertIn(usersite, sys.path)
AssertionError: '/tmp/x/../lib/python3.8/site-packages' not found in ['/usr/local/src/sage-config/local/src/cpython', '/usr/local/src/sage-config/local/lib/python38.zip', '/usr/local/src/sage-config/local/src/cpython/Lib', '/usr/local/src/sage-config/local/src/cpython/build/lib.linux-x86_64-3.8', '/usr/local/src/sage-config/local/lib/python3.8/site-packages']
msg315088 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-04-08 18:16
Would you care to provide a PR fix with a test?
msg315135 - (view) Author: Akshay Sharma (akshaysharma096) * Date: 2018-04-09 16:25
What are the possible cases we can have here ?
msg412182 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-31 00:24
I tested on a map and I only got the failure in test_s_option, which seems right because that directory is indeed not in sys.path.
msg412184 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-01-31 00:37
FWIW, I still see the same failures with 3.10.2 on a current macOS 12.2 system.
msg412185 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-31 00:40
I tested 3.11 (on a Mac 11.6).
msg412186 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-01-31 00:54
> I tested 3.11 (on a Mac 11.6).

It still fails for me on current main HEAD (on 12.2 FWIW):

$ ./configure --prefix=/tmp/p
$ make -j6
$ mkdir /tmp/x
$ export PYTHONUSERBASE=/tmp/x/..
$ ./python -m test -w test_site test_sysconfig
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 0.99 Run tests sequentially
0:00:00 load avg: 0.99 [1/2] test_site
test test_site failed -- multiple errors occurred; run in verbose mode for details
0:00:00 load avg: 0.99 [2/2/1] test_sysconfig -- test_site failed (2 failures)
test test_sysconfig failed -- Traceback (most recent call last):
  File "/Users/nad/Projects/PyDev/active/dev/3x/source/Lib/test/test_sysconfig.py", line 314, in test_user_similar
    self.assertEqual(user_path, expected)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/tmp/lib/python3.11' != '/tmp/x/../lib/python3.11'
- /tmp/lib/python3.11
+ /tmp/x/../lib/python3.11
?     +++++


test_sysconfig failed (1 failure)

== Tests result: FAILURE ==

2 tests failed:
    test_site test_sysconfig
0:00:00 load avg: 0.99
0:00:00 load avg: 0.99 Re-running failed tests in verbose mode
0:00:00 load avg: 0.99 Re-running test_site in verbose mode (matching: test_get_path, test_s_option)
test_get_path (test.test_site.HelperFunctionsTests) ... FAIL
test_s_option (test.test_site.HelperFunctionsTests) ... FAIL

======================================================================
FAIL: test_get_path (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nad/Projects/PyDev/active/dev/3x/source/Lib/test/test_site.py", line 209, in test_get_path
    self.assertEqual(site._get_path(site._getuserbase()),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/tmp/x/../lib/python/site-packages' != '/tmp/lib/python/site-packages'
- /tmp/x/../lib/python/site-packages
?     -----
+ /tmp/lib/python/site-packages


======================================================================
FAIL: test_s_option (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nad/Projects/PyDev/active/dev/3x/source/Lib/test/test_site.py", line 218, in test_s_option
    self.assertIn(usersite, sys.path)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/tmp/x/../lib/python3.11/site-packages' not found in ['/Users/nad/Projects/PyDev/active/dev/3x/source', '/tmp/p/lib/python311.zip', '/Users/nad/Projects/PyDev/active/dev/3x/source/Lib', '/Users/nad/Projects/PyDev/active/dev/3x/source/build/lib.macosx-12.2-x86_64-3.11', '/tmp/lib/python3.11/site-packages']

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (failures=2)
test test_site failed
0:00:00 load avg: 0.99 Re-running test_sysconfig in verbose mode (matching: test_user_similar)
test_user_similar (test.test_sysconfig.TestSysConfig) ... FAIL

======================================================================
FAIL: test_user_similar (test.test_sysconfig.TestSysConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nad/Projects/PyDev/active/dev/3x/source/Lib/test/test_sysconfig.py", line 314, in test_user_similar
    self.assertEqual(user_path, expected)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/tmp/lib/python3.11' != '/tmp/x/../lib/python3.11'
- /tmp/lib/python3.11
+ /tmp/x/../lib/python3.11
?     +++++


----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)
test test_sysconfig failed
2 tests failed again:
    test_site test_sysconfig

== Tests result: FAILURE then FAILURE ==

2 tests failed:
    test_site test_sysconfig

2 re-run tests:
    test_site test_sysconfig

Total duration: 350 ms
Tests result: FAILURE then FAILURE
msg412187 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-31 01:00
Maybe I did something wrong. Will check tomorrow. In the meantime I’m updating the versions. Thanks for double checking.
History
Date User Action Args
2022-04-11 14:58:59adminsetgithub: 77403
2022-01-31 01:00:24iritkatrielsetresolution: out of date ->
messages: + msg412187
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.8
2022-01-31 00:54:23ned.deilysetmessages: + msg412186
2022-01-31 00:40:22iritkatrielsetmessages: + msg412185
2022-01-31 00:37:53ned.deilysetstatus: pending -> open

messages: + msg412184
2022-01-31 00:24:53iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg412182

resolution: out of date
2018-04-09 17:21:40akshaysharmasetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request6130
2018-04-09 16:25:53akshaysharma096setnosy: + akshaysharma096
messages: + msg315135
2018-04-08 18:16:23ned.deilysetnosy: + ned.deily
messages: + msg315088

keywords: + easy
stage: needs patch
2018-04-05 07:22:29nitishchsetnosy: + nitishch
2018-04-04 14:00:04jdemeyercreate