1import mock 2 3import pytest_virtualenv as venv 4from pytest_shutil import env 5 6 7def test_PYTHONPATH_not_present_in_testing_env_if_set(): 8 with env.set_env('PYTHONPATH', 'fred'): 9 with mock.patch.object(venv.Workspace, 'run') as run: 10 venv.VirtualEnv() 11 call = run.mock_calls[0] 12 assert 'PYTHONPATH' not in call[2]['env'] 13 14 venv.VirtualEnv({'PYTHONPATH': 'john'}) 15 call = run.mock_calls[1] 16 assert 'PYTHONPATH' not in call[2]['env'] 17 18 19def test_PYTHONPATH_not_present_in_testing_env_if_unset(): 20 with env.no_env('PYTHONPATH'): 21 with mock.patch.object(venv.Workspace, 'run') as run: 22 venv.VirtualEnv() 23 call = run.mock_calls[0] 24 assert 'PYTHONPATH' not in call[2]['env'] 25 26 venv.VirtualEnv({'PYTHONPATH': 'john'}) 27 call = run.mock_calls[1] 28 assert 'PYTHONPATH' not in call[2]['env'] 29