MCPcopy
hub / github.com/pex-tool/pex / pythonpath_isolation_test

Function pythonpath_isolation_test

tests/test_pex.py:396–443  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

394
395@pytest.fixture(scope="module")
396def pythonpath_isolation_test():
397 # type: () -> Iterator[PythonpathIsolationTest]
398 with temporary_dir() as temp_dir:
399 pythonpath = os.path.join(temp_dir, "one")
400 with safe_open(os.path.join(pythonpath, "foo.py"), "w") as fp:
401 fp.write("BAR = 42")
402 with safe_open(os.path.join(pythonpath, "bar.py"), "w") as fp:
403 fp.write("FOO = 137")
404
405 dist_content = {
406 "setup.py": textwrap.dedent(
407 """
408 from setuptools import setup
409
410 setup(
411 name='foo',
412 version='0.0.0',
413 zip_safe=True,
414 packages=['foo'],
415 install_requires=[],
416 )
417 """
418 ),
419 "foo/__init__.py": "BAR = 137",
420 }
421
422 with temporary_content(dist_content) as project_dir:
423 foo_bdist = install_wheel(WheelBuilder(project_dir).bdist())
424
425 exe_contents = textwrap.dedent(
426 """
427 import sys
428
429 try:
430 import bar
431 except ImportError:
432 import collections
433 bar = collections.namedtuple('bar', ['FOO'])(None)
434
435 import foo
436
437 sys.stdout.write("foo.BAR={} bar.FOO={}".format(foo.BAR, bar.FOO))
438 """
439 )
440
441 yield PythonpathIsolationTest(
442 pythonpath=pythonpath, dists=[foo_bdist], exe=exe_contents
443 )
444
445
446def test_pythonpath_isolation_inherit_path_false(pythonpath_isolation_test):

Callers

nothing calls this directly

Calls 9

temporary_dirFunction · 0.90
safe_openFunction · 0.90
temporary_contentFunction · 0.90
install_wheelFunction · 0.90
WheelBuilderClass · 0.90
bdistMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected