Created
July 30, 2015 17:56
-
-
Save edc/aa2cf49d9662e4034f60 to your computer and use it in GitHub Desktop.
How to fail an import in tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mock | |
import sys | |
class Finder(object): | |
def find_module(self, name, path=None): | |
print name, path | |
raise ImportError | |
import threading | |
with mock.patch.object(sys, 'meta_path', [Finder()]): | |
sys.modules.pop('threading', None) | |
import threading |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment