classification
Title: lib2to3 and packaging tests fail because they write into protected directory
Type: behavior Stage: resolved
Components: Distutils2, Tests Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, benjamin.peterson, eric.araujo, python-dev, python272, tarek, vinay.sajip
Priority: normal Keywords:

Created on 2011-06-14 08:25 by vinay.sajip, last changed 2011-08-01 12:52 by eric.araujo. This issue is now closed.

Messages (7)
msg138302 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2011-06-14 08:25
Some of the tests for lib2to3 write into folders which are protected in an installed Python. This means that regression tests fail when run on an installed Python, even though they run wihtout these errors on a source build. I think writes should be done into temp files, so that you can run regressions on installed Pythons.

Example failure:

======================================================================
ERROR: test_refactor_file (lib2to3.tests.test_refactor.TestRefactoringTool)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/lib2to3/tests/test_refactor.py", line 190, in check_file_refactoring
    rt.refactor_file(test_file, True)
  File "/usr/local/lib/python3.3/lib2to3/refactor.py", line 353, in refactor_file
    write=write, encoding=encoding)
  File "/usr/local/lib/python3.3/lib2to3/refactor.py", line 518, in processed_file
    self.write_file(new_text, filename, old_text, encoding)
  File "/usr/local/lib/python3.3/lib2to3/refactor.py", line 530, in write_file
    f = _open_with_encoding(filename, "w", encoding=encoding)
IOError: [Errno 13] Permission denied: '/usr/local/lib/python3.3/lib2to3/tests/data/fixers/parrot_example.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.3/lib2to3/tests/test_refactor.py", line 200, in test_refactor_file
    self.check_file_refactoring(test_file, _DEFAULT_FIXERS)
  File "/usr/local/lib/python3.3/lib2to3/tests/test_refactor.py", line 194, in check_file_refactoring
    with open(test_file, "wb") as fp:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python3.3/lib2to3/tests/data/fixers/parrot_example.py'
msg138309 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2011-06-14 11:03
Some packaging tests also fail, for similar reasons:

======================================================================
ERROR: test_get_distinfo_file (packaging.tests.test_database.TestDistribution)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/packaging/tests/test_database.py", line 114, in setUp
    with open(record_file, 'w') as file:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python3.3/packaging/tests/fake_dists/babar-0.1.dist-info/RECORD'
msg138321 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-14 15:00
This should not be too hard to fix: I’ll move the directory with the mock projects to a temp dir, add that to sys.path, and then we’ll be able to read and write.
msg141020 - (view) Author: (python272) Date: 2011-07-23 21:42
problem exists in python 2.7.2 (should this be reported as a separate issue?)

[Python-2.7.2]$ python -m test.regrtest  -v test_lib2to3
...
ERROR: test_bom (lib2to3.tests.test_refactor.TestRefactoringTool)
...
ERROR: test_crlf_newlines 
ERROR: test_file_encoding
ERROR: test_refactor_file
...

e.g.,

  File "/usr/local/lib/python2.7/lib2to3/tests/test_refactor.py", line 194, in check_file_refactoring
    with open(test_file, "wb") as fp:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/lib2to3/tests/data/fixers/parrot_example.py'
...
[test]# ls -l /usr/local/lib/python2.7/lib2to3/tests/data/fixers/parrot_example.py 
-rw-r--r-- 1 root root 23 2011-07-23 11:48 /usr/local/lib/python2.7/lib2to3/tests/data/fixers/parrot_example.py
msg141497 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-01 12:45
New changeset 2b5a0c4e052b by Éric Araujo in branch '3.2':
Stop trying to write into the stdlib during lib2to3 tests (#12331).
http://hg.python.org/cpython/rev/2b5a0c4e052b

New changeset 7ee8f413188e by Éric Araujo in branch 'default':
Stop trying to write into the stdlib during packaging tests (#12331).
http://hg.python.org/cpython/rev/7ee8f413188e
msg141498 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-01 12:49
New changeset a425408f1e52 by Éric Araujo in branch '2.7':
Stop trying to write into the stdlib during lib2to3 tests (#12331).
http://hg.python.org/cpython/rev/a425408f1e52
msg141501 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-01 12:52
This is now fixed.  Let me just eat these words: “This should not be too hard to fix”.
History
Date User Action Args
2011-08-01 12:52:14eric.araujosetstatus: open -> closed
resolution: fixed
messages: + msg141501

stage: needs patch -> resolved
2011-08-01 12:49:57python-devsetmessages: + msg141498
2011-08-01 12:45:25python-devsetnosy: + python-dev
messages: + msg141497
2011-07-23 21:45:31eric.araujosetversions: + Python 2.7, Python 3.2
2011-07-23 21:42:21python272setnosy: + python272
messages: + msg141020
2011-06-14 15:00:43eric.araujosetassignee: tarek -> eric.araujo
messages: + msg138321
2011-06-14 14:30:52pitrousetassignee: tarek

nosy: + alexis, tarek
components: + Distutils2
stage: needs patch
2011-06-14 11:03:11vinay.sajipsettitle: lib2to3 tests write into protected directory -> lib2to3 and packaging tests fail because they write into protected directory
nosy: + eric.araujo

messages: + msg138309

components: - 2to3 (2.x to 3.x conversion tool)
2011-06-14 08:25:48vinay.sajipsettype: behavior
2011-06-14 08:25:04vinay.sajipcreate