From 4ef71160c871b225078917c17f4393146838ee4b Mon Sep 17 00:00:00 2001 From: Emile Anclin Date: Mon, 13 Sep 2010 15:09:57 +0200 Subject: [py3k] add callable to compat.py import "callable" where needed. We can't use collections in python <= 2.5 --- testlib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'testlib.py') diff --git a/testlib.py b/testlib.py index 6cbba42..df5a3f8 100644 --- a/testlib.py +++ b/testlib.py @@ -78,7 +78,8 @@ except ImportError: test_support = TestSupport() # pylint: disable=W0622 -from logilab.common.compat import set, enumerate, any, sorted, InheritableSet +from logilab.common.compat import (set, enumerate, any, sorted, InheritableSet, + callable) # pylint: enable-msg=W0622 from logilab.common.modutils import load_module_from_name from logilab.common.debugger import Debugger, colorize_source -- cgit v1.2.1 From e5c13b05080459f7fb3c25d9c2ccbdd00f188df6 Mon Sep 17 00:00:00 2001 From: Emile Anclin Date: Mon, 20 Sep 2010 14:55:05 +0200 Subject: '[testlib/py3k]: replace self._exc_info by equivalent sys.exc_info Since python2.5, _exc_info is doing nothing else than returning sys.exc_info _exc_info is not available in 2.7 and 3.x. --- testlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testlib.py') diff --git a/testlib.py b/testlib.py index df5a3f8..606e3f5 100644 --- a/testlib.py +++ b/testlib.py @@ -1025,7 +1025,7 @@ class TestCase(unittest.TestCase): super(TestCase, self).__init__(methodName) # internal API changed in python2.5 if sys.version_info >= (2, 5): - self.__exc_info = self._exc_info + self.__exc_info = sys.exc_info self.__testMethodName = self._testMethodName else: # let's give easier access to _testMethodName to every subclasses -- cgit v1.2.1 From 476f19a62e414e01687dffa93943ff2214554835 Mon Sep 17 00:00:00 2001 From: Sylvain Th?nault Date: Tue, 21 Sep 2010 15:40:51 +0200 Subject: [py3k] add a is_generator to compat. --- testlib.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'testlib.py') diff --git a/testlib.py b/testlib.py index 606e3f5..78515f2 100644 --- a/testlib.py +++ b/testlib.py @@ -57,7 +57,6 @@ import math from shutil import rmtree from operator import itemgetter import warnings -from compiler.consts import CO_GENERATOR from ConfigParser import ConfigParser from itertools import dropwhile try: @@ -96,6 +95,23 @@ ENABLE_DBC = False FILE_RESTART = ".pytest.restart" +if sys.version_info >= (2, 6): + # FIXME : this does not work as expected / breaks tests on testlib + # however testlib does not work on py3k for many reasons ... + from inspect import CO_GENERATOR +else: + from compiler.consts import CO_GENERATOR + +if sys.version_info >= (3, 0): + def is_generator(function): + flags = function.__code__.co_flags + return flags & CO_GENERATOR + +else: + def is_generator(function): + flags = function.func_code.co_flags + return flags & CO_GENERATOR + # used by unittest to count the number of relevant levels in the traceback __unittest = 1 @@ -486,7 +502,6 @@ class SkipAwareTextTestRunner(unittest.TextTestRunner): testname = '%s.%s' % (test.im_class.__name__, func.__name__) else: return True # Not sure when this happens - if is_generator(func) and skipgenerator: return self.does_match_tags(func) # Let inner tests decide at run time @@ -961,10 +976,6 @@ class TestSkipped(Exception): class InnerTestSkipped(TestSkipped): """raised when a test is skipped""" -def is_generator(function): - flags = function.func_code.co_flags - return flags & CO_GENERATOR - def parse_generative_args(params): args = [] -- cgit v1.2.1