MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_sysconfig

Method test_sysconfig

Lib/test/test_venv.py:287–317  ·  view source on GitHub ↗

Test that the sysconfig functions work in a virtual environment.

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

rmtreeFunction · 0.90
strFunction · 0.85
run_with_captureMethod · 0.80
envpyMethod · 0.80
subTestMethod · 0.80
check_outputFunction · 0.70
assertEqualMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected