summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_embed.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-09-17 22:31:31 (GMT)
committerGitHub <noreply@github.com>2021-09-17 22:31:31 (GMT)
commit090591636c4f03ce06a039079bd7716a5b23631e (patch)
tree09de3850118af9103e697ad3f2eb514e0b4fb2a4 /Lib/test/test_embed.py
parent74cc2453ae690be940cddfae8caf8216d8628c4a (diff)
downloadcpython-090591636c4f03ce06a039079bd7716a5b23631e.zip
cpython-090591636c4f03ce06a039079bd7716a5b23631e.tar.gz
cpython-090591636c4f03ce06a039079bd7716a5b23631e.tar.bz2
bpo-45020: Freeze os, site, and codecs. (gh-28398)
https://bugs.python.org/issue45020
Diffstat (limited to 'Lib/test/test_embed.py')
-rw-r--r--Lib/test/test_embed.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index e5e7c83..941e307 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -8,6 +8,7 @@ from collections import namedtuple
import contextlib
import json
import os
+import os.path
import re
import shutil
import subprocess
@@ -52,15 +53,13 @@ def remove_python_envvars():
class EmbeddingTestsMixin:
def setUp(self):
- here = os.path.abspath(__file__)
- basepath = os.path.dirname(os.path.dirname(os.path.dirname(here)))
exename = "_testembed"
if MS_WINDOWS:
ext = ("_d" if debug_build(sys.executable) else "") + ".exe"
exename += ext
exepath = os.path.dirname(sys.executable)
else:
- exepath = os.path.join(basepath, "Programs")
+ exepath = os.path.join(support.REPO_ROOT, "Programs")
self.test_exe = exe = os.path.join(exepath, exename)
if not os.path.exists(exe):
self.skipTest("%r doesn't exist" % exe)
@@ -68,7 +67,7 @@ class EmbeddingTestsMixin:
# "Py_Initialize: Unable to get the locale encoding
# LookupError: no codec search functions registered: can't find encoding"
self.oldcwd = os.getcwd()
- os.chdir(basepath)
+ os.chdir(support.REPO_ROOT)
def tearDown(self):
os.chdir(self.oldcwd)
@@ -1304,7 +1303,10 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
lib_dynload = os.path.join(pyvenv_home, 'lib')
os.makedirs(lib_dynload)
# getpathp.c uses Lib\os.py as the LANDMARK
- shutil.copyfile(os.__file__, os.path.join(lib_dynload, 'os.py'))
+ shutil.copyfile(
+ os.path.join(support.STDLIB_DIR, 'os.py'),
+ os.path.join(lib_dynload, 'os.py'),
+ )
filename = os.path.join(tmpdir, 'pyvenv.cfg')
with open(filename, "w", encoding="utf8") as fp: