Added test for previous crash on failed import fix
Also, rewrote the fix a bit. ref #383.
This commit is contained in:
@@ -307,6 +307,24 @@ class TestGeneralUsage:
|
||||
'*ERROR*',
|
||||
])
|
||||
assert result.ret == 4 # usage error only if item not found
|
||||
|
||||
def test_namespace_import_doesnt_confuse_import_hook(self, testdir):
|
||||
# Ref #383. Python 3.3's namespace package messed with our import hooks
|
||||
# Importing a module that didn't exist, even if the ImportError was
|
||||
# gracefully handled, would make our test crash.
|
||||
testdir.mkdir('not_a_package')
|
||||
p = testdir.makepyfile("""
|
||||
try:
|
||||
from not_a_package import doesnt_exist
|
||||
except ImportError:
|
||||
# We handle the import error gracefully here
|
||||
pass
|
||||
|
||||
def test_whatever():
|
||||
pass
|
||||
""")
|
||||
res = testdir.runpytest(p.basename)
|
||||
assert res.ret == 0
|
||||
|
||||
|
||||
class TestInvocationVariants:
|
||||
|
||||
Reference in New Issue
Block a user