diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2021-04-27 08:45:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-27 08:45:55 (GMT) |
commit | d92513390a1a0da781bb08c284136f4d7abea36d (patch) | |
tree | 08a76862793078b24e7f54861829dc0fbd8a9684 /Lib/test | |
parent | 93f411838a95f6acbcc29d16ecfd10093cfd5cfd (diff) | |
download | cpython-d92513390a1a0da781bb08c284136f4d7abea36d.zip cpython-d92513390a1a0da781bb08c284136f4d7abea36d.tar.gz cpython-d92513390a1a0da781bb08c284136f4d7abea36d.tar.bz2 |
bpo-43312: Functions returning default and preferred sysconfig schemes (GH-24644)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_sysconfig.py | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index e279957..b8b9add 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -14,8 +14,8 @@ from test.support.warnings_helper import check_warnings import sysconfig from sysconfig import (get_paths, get_platform, get_config_vars, get_path, get_path_names, _INSTALL_SCHEMES, - _get_default_scheme, _expand_vars, - get_scheme_names, get_config_var, _main) + get_default_scheme, get_scheme_names, get_config_var, + _expand_vars, _get_preferred_schemes, _main) import _osx_support @@ -94,17 +94,46 @@ class TestSysConfig(unittest.TestCase): def test_get_paths(self): scheme = get_paths() - default_scheme = _get_default_scheme() + default_scheme = get_default_scheme() wanted = _expand_vars(default_scheme, None) wanted = sorted(wanted.items()) scheme = sorted(scheme.items()) self.assertEqual(scheme, wanted) def test_get_path(self): - # XXX make real tests here + config_vars = get_config_vars() for scheme in _INSTALL_SCHEMES: for name in _INSTALL_SCHEMES[scheme]: - res = get_path(name, scheme) + expected = _INSTALL_SCHEMES[scheme][name].format(**config_vars) + self.assertEqual( + os.path.normpath(get_path(name, scheme)), + os.path.normpath(expected), + ) + + def test_get_default_scheme(self): + self.assertIn(get_default_scheme(), _INSTALL_SCHEMES) + + def test_get_preferred_schemes(self): + expected_schemes = {'prefix', 'home', 'user'} + + # Windows. + os.name = 'nt' + schemes = _get_preferred_schemes() + self.assertIsInstance(schemes, dict) + self.assertEqual(set(schemes), expected_schemes) + + # Mac and Linux, shared library build. + os.name = 'posix' + schemes = _get_preferred_schemes() + self.assertIsInstance(schemes, dict) + self.assertEqual(set(schemes), expected_schemes) + + # Mac, framework build. + os.name = 'posix' + sys.platform = 'darwin' + sys._framework = True + self.assertIsInstance(schemes, dict) + self.assertEqual(set(schemes), expected_schemes) def test_get_config_vars(self): cvars = get_config_vars() |