8000 gh-108303: Move `double_const` to `test_import` where it belongs by sobolevn · Pull Request #112108 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-108303: Move double_const to test_import where it belongs #112108

New iss 10000 ue

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

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify import
  • Loading branch information
sobolevn committed Nov 15, 2023
commit 0af9fb6ff78ebe7dcda004aff4ee235f8c6d54d2
25 changes: 3 additions & 22 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,28 +876,9 @@ def test_double_const(self):
# Importing double_const checks that float constants
# serialiazed by marshal as PYC files don't lose precision
# (SF bug 422177).
filepath = os.path.join(
TEST_HOME_DIR,
'test_import',
'data',
'double_const.py',
)

with open(filepath, 'r', encoding='utf8') as f:
source = f.read()

with ready_to_import(source=source) as (name, path):
# Initial import should be fine:
__import__(name)

# Now, delete source file, only keep `.pyc` file and import again:
unlink(path)
unload(name)
importlib.invalidate_caches()

bytecode_only = path + 'c'
os.rename(importlib.util.cache_from_source(path), bytecode_only)
__import__(name)
from test.test_import.data import double_const
unload('test.test_import.data.double_const')
from test.test_import.data import double_const


class PycRewritingTests(unittest.TestCase):
Expand Down
0