python/mock-1.0.0/tests/support.py
author Xavier Fung <xavier114fch@gmail.com>
Wed, 03 Jul 2013 10:52:32 +0900
changeset 149559 a52babf286bc89980f537718c9b8d866934a2569
parent 120523 5981ff9d3f45de802d956b2f8e064f49b74cb7a6
permissions -rw-r--r--
Bug 888158 - Make configure to detect Visual Studio 2013 compiler. r=ted

import sys

info = sys.version_info
if info[:3] >= (3, 2, 0):
    # for Python 3.2 ordinary unittest is fine
    import unittest as unittest2
else:
    import unittest2


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


inPy3k = sys.version_info[0] == 3
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()