1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/python/mock-1.0.0/tests/support.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 +import sys 1.5 + 1.6 +info = sys.version_info 1.7 +if info[:3] >= (3, 2, 0): 1.8 + # for Python 3.2 ordinary unittest is fine 1.9 + import unittest as unittest2 1.10 +else: 1.11 + import unittest2 1.12 + 1.13 + 1.14 +try: 1.15 + callable = callable 1.16 +except NameError: 1.17 + def callable(obj): 1.18 + return hasattr(obj, '__call__') 1.19 + 1.20 + 1.21 +inPy3k = sys.version_info[0] == 3 1.22 +with_available = sys.version_info[:2] >= (2, 5) 1.23 + 1.24 + 1.25 +def is_instance(obj, klass): 1.26 + """Version of is_instance that doesn't access __class__""" 1.27 + return issubclass(type(obj), klass) 1.28 + 1.29 + 1.30 +class SomeClass(object): 1.31 + class_attribute = None 1.32 + 1.33 + def wibble(self): 1.34 + pass 1.35 + 1.36 + 1.37 +class X(object): 1.38 + pass 1.39 + 1.40 +try: 1.41 + next = next 1.42 +except NameError: 1.43 + def next(obj): 1.44 + return obj.next()