Suppose I have a module that does something like this:
try:
from foo import bar
except ImportError:
def bar():
pass
How do I test the except ImportError block with pytest?
Suppose I have a module that does something like this:
try:
from foo import bar
except ImportError:
def bar():
pass
How do I test the except ImportError block with pytest?
you can mock the behavior of bar to raise an ImportError on import within your test. I would take a look at this