classification
Title: test_site failure when .local/lib/pythonX.Y/site-packages hasn't been created yet
Type: behavior Stage:
Components: Tests Versions: Python 3.6, Python 3.5, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, martin.panter, ned.deily, pitrou, serhiy.storchaka, tarek, yjchen
Priority: normal Keywords:

Created on 2009-11-08 00:27 by pitrou, last changed 2015-12-13 02:37 by martin.panter.

Messages (9)
msg95031 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-08 00:27
On that buildbot, /var/lib/buildbot is a symlink to /home/buildbot and I
get the following failure:

======================================================================
FAIL: test_s_option (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/buildbot/cpython-ucs2/3.x.pitrou-ubuntu/build/Lib/test/test_site.py",
line 107, in test_s_option
    self.assertIn(usersite, sys.path)
AssertionError: '/var/lib/buildbot/.local/lib/python3.2/site-packages'
not found in ['/usr/local/lib/python32.zip',
'/home/buildbot/cpython-ucs2/3.x.pitrou-ubuntu/build/Lib',
'/home/buildbot/cpython-ucs2/3.x.pitrou-ubuntu/build/Lib/plat-linux2',
'/home/buildbot/cpython-ucs2/3.x.pitrou-ubuntu/build/Modules',
'/home/buildbot/cpython-ucs2/3.x.pitrou-ubuntu/build/build/lib.linux-x86_64-3.2-pydebug']

----------------------------------------------------------------------
msg95032 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-08 00:28
Well, I'm not sure the symlink is actually the problem. Apparently the
".local" directory hadn't been created when the first test run.
msg122093 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 04:45
Is this still relevant?
msg138003 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-09 16:21
Related: I found that test_site tries to create the user site-packages dir if it does not exist, but it does not remove it after the test run.
msg221301 - (view) Author: YJ Chen (yjchen) Date: 2014-06-22 19:46
Works for 3.4 and 3.5 but could not successfully run test on 2.7.

Error:
======================================================================
FAIL: test_getsitepackages (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/test/test_site.py", line 247, in test_getsitepackages
    self.assertEqual(len(dirs), 4)
AssertionError: 2 != 4

======================================================================
FAIL: test_getuserbase (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/test/test_site.py", line 210, in test_getuserbase
    site.getuserbase())
AssertionError: /Users/yjchen/Library/Python/2.7

======================================================================
FAIL: test_s_option (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/test/test_site.py", line 193, in test_s_option
    self.assertEqual(rc, 1)
AssertionError: 0 != 1

----------------------------------------------------------------------
msg221320 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-22 22:23
YJ, the test_site failures you are seeing should have been fixed by the changes for Issue10881 (82c4f094f811) that were released with Python 2.7.3.  Please update your Python 2.7 to the latest release (currently 2.7.7).

Otherwise, unless somebody is able to reproduce the original failure (I can't so far), I think we should close this issue.
msg225546 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-08-19 22:37
Closing, since this problem apparently no longer occurs
msg256289 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-12 17:41
This problem still occurs.

http://buildbot.python.org/all/builders/x86-64%20Ubuntu%2014.04%20ICC%20Debug%203.5/builds/275/steps/test/logs/stdio

======================================================================
FAIL: test_s_option (test.test_site.HelperFunctionsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/buildarea/3.5.intel-ubuntu-icc/build/Lib/test/test_site.py", line 169, in test_s_option
    self.assertIn(usersite, sys.path)
AssertionError: '/var/lib/buildbot/.local/lib/python3.5/site-packages' not found in ['', '/usr/local/lib/python35.zip', '/buildarea/3.5.intel-ubuntu-icc/build/Lib', '/buildarea/3.5.intel-ubuntu-icc/build/Lib/plat-linux', '/buildarea/3.5.intel-ubuntu-icc/build/build/lib.linux-x86_64-3.5-pydebug']

----------------------------------------------------------------------

On 3.5 the test is failed randomly, on 3.4 it is failed all time.

I can't reproduce this locally. If remove ~/.local/lib/pythonX.Y and run test_site, it creates the directory and modifies sys.path (this is a bug).

$ rm -rf ~/.local/lib/python3.4
$ ./python -m test.regrtest -uall -vv test_site
...
Ran 21 tests in 0.277s

OK (skipped=2)
Warning -- sys.path was modified by test_site
  Before: (3071378764, ['', '/usr/local/lib/python34.zip', '/home/serhiy/py/cpython3.4/Lib', '/home/serhiy/py/cpython3.4/Lib/plat-linux', '/home/serhiy/py/cpython3.4/build/lib.linux-i686-3.4'], ['', '/usr/local/lib/python34.zip', '/home/serhiy/py/cpython3.4/Lib', '/home/serhiy/py/cpython3.4/Lib/plat-linux', '/home/serhiy/py/cpython3.4/build/lib.linux-i686-3.4'])
  After:  (3071378764, ['', '/usr/local/lib/python34.zip', '/home/serhiy/py/cpython3.4/Lib', '/home/serhiy/py/cpython3.4/Lib/plat-linux', '/home/serhiy/py/cpython3.4/build/lib.linux-i686-3.4'], ['', '/usr/local/lib/python34.zip', '/home/serhiy/py/cpython3.4/Lib', '/home/serhiy/py/cpython3.4/Lib/plat-linux', '/home/serhiy/py/cpython3.4/build/lib.linux-i686-3.4', '/home/serhiy/.local/lib/python3.4/site-packages']) 
1 test altered the execution environment:
    test_site
msg256312 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-13 02:37
I can’t imagine why the buildbot is failing either.

The directory is created and added to sys.path when test_site is imported:

if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
    # need to add user site directory for tests
    os.makedirs(site.USER_SITE)
    site.addsitedir(site.USER_SITE)

Maybe it should be changed to skip test_s_option() if the directory is missing; I dunno. Another option might be to create it just for the test, and then remove it, but that risks interfering with concurrent tests.
History
Date User Action Args
2015-12-13 02:37:20martin.pantersetnosy: + martin.panter
messages: + msg256312
2015-12-12 17:41:30serhiy.storchakasetstatus: closed -> open

versions: + Python 3.6
nosy: + serhiy.storchaka

messages: + msg256289
resolution: out of date ->
stage: resolved ->
2014-08-19 22:37:49ned.deilysetstatus: open -> closed
resolution: out of date
messages: + msg225546

stage: needs patch -> resolved
2014-06-22 22:23:17ned.deilysetnosy: + ned.deily
messages: + msg221320
2014-06-22 19:46:59yjchensetnosy: + yjchen
messages: + msg221301
2014-06-20 15:44:18zach.waresetassignee: tarek ->
versions: + Python 3.4, Python 3.5, - Python 3.2
2011-06-09 16:21:01eric.araujosetmessages: + msg138003
2010-11-22 04:45:27eric.araujosetnosy: + eric.araujo
messages: + msg122093
2009-11-08 00:51:38pitrousettitle: test_site failure when Python gets installed along a symbolic link -> test_site failure when .local/lib/pythonX.Y/site-packages hasn't been created yet
2009-11-08 00:28:25pitrousetmessages: + msg95032
2009-11-08 00:27:12pitroucreate