Test that the sysconfig functions work in a virtual environment.
(self)
| 279 | |
| 280 | @requireVenvCreate |
| 281 | def test_sysconfig(self): |
| 282 | """ |
| 283 | Test that the sysconfig functions work in a virtual environment. |
| 284 | """ |
| 285 | rmtree(self.env_dir) |
| 286 | self.run_with_capture(venv.create, self.env_dir, symlinks=False) |
| 287 | cmd = [self.envpy(), '-c', None] |
| 288 | for call, expected in ( |
| 289 | # installation scheme |
| 290 | ('get_preferred_scheme("prefix")', 'venv'), |
| 291 | ('get_default_scheme()', 'venv'), |
| 292 | # build environment |
| 293 | ('is_python_build()', str(sysconfig.is_python_build())), |
| 294 | ('get_makefile_filename()', sysconfig.get_makefile_filename()), |
| 295 | ('get_config_h_filename()', sysconfig.get_config_h_filename()), |
| 296 | ('get_config_var("Py_GIL_DISABLED")', |
| 297 | str(sysconfig.get_config_var("Py_GIL_DISABLED")))): |
| 298 | with self.subTest(call): |
| 299 | cmd[2] = 'import sysconfig; print(sysconfig.%s)' % call |
| 300 | out, err = check_output(cmd, encoding='utf-8') |
| 301 | self.assertEqual(out.strip(), expected, err) |
| 302 | for attr, expected in ( |
| 303 | ('executable', self.envpy()), |
| 304 | # Usually compare to sys.executable, but if we're running in our own |
| 305 | # venv then we really need to compare to our base executable |
| 306 | ('_base_executable', sys._base_executable), |
| 307 | ): |
| 308 | with self.subTest(attr): |
| 309 | cmd[2] = f'import sys; print(sys.{attr})' |
| 310 | out, err = check_output(cmd, encoding='utf-8') |
| 311 | self.assertEqual(out.strip(), expected, err) |
| 312 | |
| 313 | @requireVenvCreate |
| 314 | @unittest.skipUnless(can_symlink(), 'Needs symlinks') |
nothing calls this directly
no test coverage detected