From 345266aa7e7fdbb1bbf3ffd244caff39406d46d2 Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Wed, 14 Mar 2012 12:24:34 -0700 Subject: PEP 417: Adding unittest.mock --- Lib/unittest/test/testmock/support.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Lib/unittest/test/testmock/support.py (limited to 'Lib/unittest/test/testmock/support.py') diff --git a/Lib/unittest/test/testmock/support.py b/Lib/unittest/test/testmock/support.py new file mode 100644 index 0000000000..f4738793b3 --- /dev/null +++ b/Lib/unittest/test/testmock/support.py @@ -0,0 +1,23 @@ +import sys + +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 + + +def examine_warnings(func): + def wrapper(): + with catch_warnings(record=True) as ws: + func(ws) + return wrapper -- cgit v1.2.1