blob: 1b10c3428f3ab5dfa8071f3472ce3ab2042c188e [file] [log] [blame]
Michael Foord1e68bec2012-03-03 22:24:30 +00001import sys
2
3info = sys.version_info
4if info[:3] >= (3, 2, 0):
5 # for Python 3.2 ordinary unittest is fine
6 import unittest as unittest2
7else:
8 import unittest2
9
10
11try:
12 callable = callable
13except NameError:
14 def callable(obj):
15 return hasattr(obj, '__call__')
16
17
18inPy3k = sys.version_info[0] == 3
19with_available = sys.version_info[:2] >= (2, 5)
20
21
22def is_instance(obj, klass):
23 """Version of is_instance that doesn't access __class__"""
24 return issubclass(type(obj), klass)
25
26
27class SomeClass(object):
28 class_attribute = None
29
30 def wibble(self):
31 pass
32
33
34class X(object):
35 pass
36
37try:
38 next = next
39except NameError:
40 def next(obj):
41 return obj.next()