def test_find_module(self): import pickle # ensure this test is decoupled from global imports _find_module('pickle') with pytest.raises(ImportError): _find_module('invalid_module') with pytest.raises(ImportError): valid_module = imp.new_module('valid_module') _find_module('valid_module')