futurize code also add ability to fetch a method's class depending on whether the system is py2 or py3

This commit is contained in:
Kurt Grandis 2015-06-25 01:41:05 -04:00
parent f413cd9396
commit 0717e443fd
2 changed files with 12 additions and 2 deletions

View File

@ -1,9 +1,17 @@
from __future__ import unicode_literals
import sys
import os
import logging
from nose.plugins import Plugin
log = logging.getLogger('nose.plugins.nose_exclude')
if sys.version_info > (3,):
get_method_class = lambda x: x.__self__.__class__
else:
get_method_class = lambda x: x.im_class
class NoseExclude(Plugin):
@ -108,7 +116,7 @@ class NoseExclude(Plugin):
if abs_d:
self.exclude_dirs[abs_d] = True
exclude_str = "excluding dirs: %s" % ",".join(self.exclude_dirs.keys())
exclude_str = "excluding dirs: %s" % ",".join(list(self.exclude_dirs.keys()))
log.debug(exclude_str)
def wantDirectory(self, dirname):
@ -140,7 +148,7 @@ class NoseExclude(Plugin):
def wantMethod(self, meth):
"""Filter out tests based on <module path>.<class>.<method name>"""
try:
cls = meth.im_class # Don't test static methods
cls = get_method_class(meth)
except AttributeError:
return False

View File

@ -1,5 +1,6 @@
import unittest
class UnitTests(unittest.TestCase):
def test_a(self):
assert True
@ -7,5 +8,6 @@ class UnitTests(unittest.TestCase):
def test_b(self):
assert True
def test_c():
assert True