diff options
Diffstat (limited to 'mock/tests/support.py')
-rw-r--r-- | mock/tests/support.py | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/mock/tests/support.py b/mock/tests/support.py deleted file mode 100644 index d57a372..0000000 --- a/mock/tests/support.py +++ /dev/null @@ -1,46 +0,0 @@ -import contextlib -import sys - - -target = {'foo': 'FOO'} - - -def is_instance(obj, klass): - """Version of is_instance that doesn't access __class__""" - return issubclass(type(obj), klass) - - -class SomeClass(object): - class_attribute = None - - def wibble(self): pass - - -class X(object): - pass - - -@contextlib.contextmanager -def uncache(*names): - """Uncache a module from sys.modules. - - A basic sanity check is performed to prevent uncaching modules that either - cannot/shouldn't be uncached. - - """ - for name in names: - if name in ('sys', 'marshal', 'imp'): - raise ValueError( - "cannot uncache {0}".format(name)) - try: - del sys.modules[name] - except KeyError: - pass - try: - yield - finally: - for name in names: - try: - del sys.modules[name] - except KeyError: - pass |