python/mock-1.0.0/tests/support.py

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 import sys
     3 info = sys.version_info
     4 if info[:3] >= (3, 2, 0):
     5     # for Python 3.2 ordinary unittest is fine
     6     import unittest as unittest2
     7 else:
     8     import unittest2
    11 try:
    12     callable = callable
    13 except NameError:
    14     def callable(obj):
    15         return hasattr(obj, '__call__')
    18 inPy3k = sys.version_info[0] == 3
    19 with_available = sys.version_info[:2] >= (2, 5)
    22 def is_instance(obj, klass):
    23     """Version of is_instance that doesn't access __class__"""
    24     return issubclass(type(obj), klass)
    27 class SomeClass(object):
    28     class_attribute = None
    30     def wibble(self):
    31         pass
    34 class X(object):
    35     pass
    37 try:
    38     next = next
    39 except NameError:
    40     def next(obj):
    41         return obj.next()

mercurial