Merged in msabramo/pytest/sys_meta_path_remove_hook_only_if_present (pull request #133)
Only try to remove hook from sys.meta_path if it's present
This commit is contained in:
commit
a65380941d
|
@ -60,7 +60,7 @@ def pytest_configure(config):
|
|||
|
||||
def pytest_unconfigure(config):
|
||||
hook = config._assertstate.hook
|
||||
if hook is not None:
|
||||
if hook is not None and hook in sys.meta_path:
|
||||
sys.meta_path.remove(hook)
|
||||
|
||||
def pytest_collection(session):
|
||||
|
|
|
@ -482,6 +482,12 @@ def test_rewritten():
|
|||
assert "@py_builtins" in globals()""".replace("\n", "\r\n"), "wb")
|
||||
assert testdir.runpytest().ret == 0
|
||||
|
||||
def test_sys_meta_path_munged(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
def test_meta_path():
|
||||
import sys; sys.meta_path = []""")
|
||||
assert testdir.runpytest().ret == 0
|
||||
|
||||
def test_write_pyc(self, testdir, tmpdir, monkeypatch):
|
||||
from _pytest.assertion.rewrite import _write_pyc
|
||||
from _pytest.assertion import AssertionState
|
||||
|
|
Loading…
Reference in New Issue