File: support.py

package info (click to toggle)
python-mock 2.0.0-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 564 kB
  • sloc: python: 5,677; sh: 37; makefile: 11
file content (36 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys

info = sys.version_info
import unittest2


try:
    callable = callable
except NameError:
    def callable(obj):
        return hasattr(obj, '__call__')


with_available = sys.version_info[:2] >= (2, 5)


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

try:
    next = next
except NameError:
    def next(obj):
        return obj.next()