假设我有一个类似这样的模块:
try: from foo import bar except ImportError: def bar(): pass
如何用pytest测试except ImportError块?
except ImportError
你可以嘲笑bar的行为,在你的测试中引导ImportError。我会看看this
bar
ImportError