Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures with PYTHONDONTWRITEBYTECODE: test_importlib, test_imp, test_distutils, test_packaging, test_runpy, test_import #56326

Closed
pitrou opened this issue May 19, 2011 · 10 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented May 19, 2011

BPO 12117
Nosy @warsaw, @brettcannon, @ncoghlan, @pitrou, @vstinner, @merwok, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-09-05.14:30:15.425>
created_at = <Date 2011-05-19.16:18:05.353>
labels = ['type-bug', 'tests']
title = 'Failures with PYTHONDONTWRITEBYTECODE: test_importlib, test_imp, test_distutils, test_packaging, test_runpy, test_import'
updated_at = <Date 2011-09-05.14:30:15.424>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2011-09-05.14:30:15.424>
actor = 'eric.araujo'
assignee = 'none'
closed = True
closed_date = <Date 2011-09-05.14:30:15.425>
closer = 'eric.araujo'
components = ['Tests']
creation = <Date 2011-05-19.16:18:05.353>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 12117
keywords = []
message_count = 10.0
messages = ['136299', '136323', '136348', '136349', '136357', '136379', '136381', '143403', '143435', '143514']
nosy_count = 9.0
nosy_names = ['barry', 'brett.cannon', 'ncoghlan', 'pitrou', 'vstinner', 'eric.araujo', 'Arfrever', 'r.david.murray', 'alexis']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12117'
versions = ['Python 3.3']

@pitrou
Copy link
Member Author

pitrou commented May 19, 2011

I get the following failure under a fresh checkout:

======================================================================
ERROR: test_file_from_empty_string_dir (importlib.test.source.test_file_loader.SimpleTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/importlib/test/source/test_file_loader.py", line 129, in test_file_from_empty_string_dir
    shutil.rmtree(pycache)
  File "/home/antoine/t/cpython/Lib/shutil.py", line 270, in rmtree
    onerror(os.listdir, path, sys.exc_info())
  File "/home/antoine/t/cpython/Lib/shutil.py", line 268, in rmtree
    names = os.listdir(path)
OSError: [Errno 2] No such file or directory: '__pycache__'

@pitrou pitrou added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels May 19, 2011
@pitrou
Copy link
Member Author

pitrou commented May 19, 2011

This is due to PYTHONDONTWRITEBYTECODE being set. Not sure this is worth fixing.

@vstinner
Copy link
Member

The following issues has been marked as a duplicate of this issue:

Tarek did the following commit to try to fix test_packaging:

New changeset 9d1fb6a9104b by Tarek Ziade in branch 'default':
Issue bpo-12120, Issue bpo-12119: tests were missing a sys.dont_write_bytecode check
http://hg.python.org/cpython/rev/9d1fb6a9104b

@vstinner
Copy link
Member

Traceback of the duplicate issues:

======================================================================
ERROR: test_issue5604 (test.test_imp.ImportTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_imp.py", line 163, in test_issue5604
    temp_mod_name, imp.cache_from_source(temp_mod_name + '.py'))
IOError: [Errno 2] No such file or directory

======================================================================
FAIL: test_package_data (distutils.tests.test_build_py.BuildPyTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/distutils/tests/test_build_py.py", line 61, in test_package_data
    self.assertTrue("__init__.pyc" in files)
AssertionError: False is not true

======================================================================
FAIL: test_package_data (packaging.tests.test_command_build_py.BuildPyTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/packaging/tests/test_command_build_py.py", line 64, in test_package_data
    self.assertIn("__init__.pyc", files)
AssertionError: '__init__.pyc' not found in ['README.txt', '__init__.py']

======================================================================
ERROR: test_explicit_relative_import (test.test_runpy.RunModuleTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 283, in test_explicit_relative_import
    self._check_relative_imports(depth)
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 257, in _check_relative_imports
    make_legacy_pyc(mod_fname)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_main_relative_import (test.test_runpy.RunModuleTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 288, in test_main_relative_import
    self._check_relative_imports(depth, "__main__")
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 257, in _check_relative_imports
    make_legacy_pyc(mod_fname)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_run_module (test.test_runpy.RunModuleTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 273, in test_run_module
    self._check_module(depth)
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 177, in _check_module
    make_legacy_pyc(mod_fname)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_run_package (test.test_runpy.RunModuleTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 278, in test_run_package
    self._check_package(depth)
  File "/home/antoine/t/cpython/Lib/test/test_runpy.py", line 201, in _check_package
    make_legacy_pyc(mod_fname)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_file_to_source (test.test_import.ImportTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 253, in test_file_to_source
    make_legacy_pyc(source)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test___cached___legacy_pyc (test.test_import.PycacheTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 584, in test___cached___legacy_pyc
    pyc_file = make_legacy_pyc(self.source)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_missing_source_legacy (test.test_import.PycacheTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 564, in test_missing_source_legacy
    pyc_file = make_legacy_pyc(self.source)
  File "/home/antoine/t/cpython/Lib/test/support.py", line 217, in make_legacy_pyc
    os.rename(pyc_file, legacy_pyc)
OSError: [Errno 2] No such file or directory

======================================================================
FAIL: test_execute_bit_not_copied (test.test_import.ImportTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 112, in test_execute_bit_not_copied
    self.fail("__import__ did not result in creation of "
AssertionError: __import__ did not result in creation of either a .pyc or .pyo file

======================================================================
FAIL: test_import_pyc_path (test.test_import.PycacheTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 531, in test_import_pyc_path
    self.assertTrue(os.path.exists('__pycache__'))
AssertionError: False is not true

======================================================================
FAIL: test_missing_source (test.test_import.PycacheTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 552, in test_missing_source
    self.assertTrue(os.path.exists(pyc_file))
AssertionError: False is not true

======================================================================
FAIL: test_unwritable_directory (test.test_import.PycacheTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/test/test_import.py", line 543, in test_unwritable_directory
    self.assertTrue(os.path.exists('__pycache__'))
AssertionError: False is not true

Antoine's setup (msg136318):

"Indeed, PYTHONDONTWRITEBYTECODE seems set by default on this Linux install... Ouch."

@vstinner vstinner changed the title test_importlib failure Failures with PYTHONDONTWRITEBYTECODE: test_importlib, test_imp, test_distutils, test_packaging, test_runpy, test_import May 20, 2011
@ncoghlan
Copy link
Contributor

Several of these could be handled just by having test.support.make_legacy_pyc() fall back to compiling from source if sys.dont_write_bytecode is set.

The others may need to be skipped in that situation.

@pitrou
Copy link
Member Author

pitrou commented May 20, 2011

Honestly, now that it's been established that it has to do with a bogus system default (on Mageia/Mandriva installs), I'm not sure it's worth fixing if it means adding more logic to the tests.

@bitdancer
Copy link
Member

In fact, not fixing it might send a small message as to what we think about that particular system default :)

@merwok
Copy link
Member

merwok commented Sep 2, 2011

Is this still relevant?

@brettcannon
Copy link
Member

Unless someone cares enough to decorate the tests that should not write the bytecode (I think I have one such decorator in the importlib tests, but I think it is more for other VMs than for this situation) then I wouldn't worry about this.

@merwok
Copy link
Member

merwok commented Sep 5, 2011

Alright, closing.

@merwok merwok closed this as completed Sep 5, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

6 participants