Test that the sysconfig functions work in a virtual environment.
(self)
| 313 | @requireVenvCreate |
| 314 | @unittest.skipUnless(can_symlink(), 'Needs symlinks') |
| 315 | def test_sysconfig_symlinks(self): |
| 316 | """ |
| 317 | Test that the sysconfig functions work in a virtual environment. |
| 318 | """ |
| 319 | rmtree(self.env_dir) |
| 320 | self.run_with_capture(venv.create, self.env_dir, symlinks=True) |
| 321 | cmd = [self.envpy(), '-c', None] |
| 322 | for call, expected in ( |
| 323 | # installation scheme |
| 324 | ('get_preferred_scheme("prefix")', 'venv'), |
| 325 | ('get_default_scheme()', 'venv'), |
| 326 | # build environment |
| 327 | ('is_python_build()', str(sysconfig.is_python_build())), |
| 328 | ('get_makefile_filename()', sysconfig.get_makefile_filename()), |
| 329 | ('get_config_h_filename()', sysconfig.get_config_h_filename()), |
| 330 | ('get_config_var("Py_GIL_DISABLED")', |
| 331 | str(sysconfig.get_config_var("Py_GIL_DISABLED")))): |
| 332 | with self.subTest(call): |
| 333 | cmd[2] = 'import sysconfig; print(sysconfig.%s)' % call |
| 334 | out, err = check_output(cmd, encoding='utf-8') |
| 335 | self.assertEqual(out.strip(), expected, err) |
| 336 | for attr, expected in ( |
| 337 | ('executable', self.envpy()), |
| 338 | # Usually compare to sys.executable, but if we're running in our own |
| 339 | # venv then we really need to compare to our base executable |
| 340 | # HACK: Test fails on POSIX with unversioned binary (PR gh-113033) |
| 341 | #('_base_executable', sys._base_executable), |
| 342 | ): |
| 343 | with self.subTest(attr): |
| 344 | cmd[2] = f'import sys; print(sys.{attr})' |
| 345 | out, err = check_output(cmd, encoding='utf-8') |
| 346 | self.assertEqual(out.strip(), expected, err) |
| 347 | |
| 348 | if sys.platform == 'win32': |
| 349 | ENV_SUBDIRS = ( |
nothing calls this directly
no test coverage detected