mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Add mock 4.0.2
This commit is contained in:
parent
c55c00a19e
commit
1dfbef89ff
14 changed files with 10635 additions and 0 deletions
52
lib/mock/tests/support.py
Normal file
52
lib/mock/tests/support.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
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:
|
||||
assert name not in ('sys', 'marshal', 'imp')
|
||||
try:
|
||||
del sys.modules[name]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
for name in names:
|
||||
del sys.modules[name]
|
||||
|
||||
|
||||
class _ALWAYS_EQ:
|
||||
"""
|
||||
Object that is equal to anything.
|
||||
"""
|
||||
def __eq__(self, other):
|
||||
return True
|
||||
def __ne__(self, other):
|
||||
return False
|
||||
|
||||
ALWAYS_EQ = _ALWAYS_EQ()
|
Loading…
Add table
Add a link
Reference in a new issue