test_sys_meta_path_munged: Simplify with makepyfile

--HG--
branch : sys_meta_path_remove_hook_only_if_present
This commit is contained in:
Marc Abramowitz 2014-03-28 01:03:52 -07:00
parent 81f822d528
commit 17d7c60735
1 changed files with 3 additions and 13 deletions

View File

@ -483,19 +483,9 @@ def test_rewritten():
assert testdir.runpytest().ret == 0 assert testdir.runpytest().ret == 0
def test_sys_meta_path_munged(self, testdir): def test_sys_meta_path_munged(self, testdir):
# In some versions, if any code messed with sys.meta_path and removed testdir.makepyfile("""
# the assertionrewrite import hook (one example is CaptureMock), it def test_meta_path():
# would cause an error on py.test exit: import sys; sys.meta_path = []""")
#
# File "/Users/marca/dev/hg-repos/pytest/_pytest/assertion/__init__.py", line 64, in pytest_unconfigure
# sys.meta_path.remove(hook)
# ValueError: list.remove(x): x not in list
#
testdir.tmpdir.join("test_meta_path.py").write("""#!/usr/bin/env python
def test_meta_path():
import sys
sys.meta_path = []
assert True""".replace("\n", "\r\n"), "wb")
assert testdir.runpytest().ret == 0 assert testdir.runpytest().ret == 0
def test_write_pyc(self, testdir, tmpdir, monkeypatch): def test_write_pyc(self, testdir, tmpdir, monkeypatch):