summaryrefslogtreecommitdiff
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-09-28 12:18:28 -0600
committerGitHub <noreply@github.com>2021-09-28 12:18:28 -0600
commit0c50b8c0b8274d54d6b71ed7bd21057d3642f138 (patch)
treeed77a5e7e69302e88349da50c5473c1aa7397d00 /Lib/test/test_sys.py
parent84975146a7ce64f1d50dcec8311b7f7188a5c962 (diff)
downloadcpython-git-0c50b8c0b8274d54d6b71ed7bd21057d3642f138.tar.gz
bpo-45211: Remember the stdlib dir during startup. (gh-28586)
During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index e98803b48f..3b80904b28 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -13,6 +13,7 @@ from test import support
from test.support import os_helper
from test.support.script_helper import assert_python_ok, assert_python_failure
from test.support import threading_helper
+from test.support import import_helper
import textwrap
import unittest
import warnings
@@ -994,6 +995,15 @@ class SysModuleTest(unittest.TestCase):
for name in sys.stdlib_module_names:
self.assertIsInstance(name, str)
+ def test_stdlib_dir(self):
+ os = import_helper.import_fresh_module('os')
+ marker = getattr(os, '__file__', None)
+ if marker and not os.path.exists(marker):
+ marker = None
+ expected = os.path.dirname(marker) if marker else None
+ actual = sys._stdlib_dir
+ self.assertEqual(actual, expected)
+
@test.support.cpython_only
class UnraisableHookTest(unittest.TestCase):