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:
parent
f413cd9396
commit
0717e443fd
|
@ -1,9 +1,17 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from nose.plugins import Plugin
|
from nose.plugins import Plugin
|
||||||
|
|
||||||
log = logging.getLogger('nose.plugins.nose_exclude')
|
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):
|
class NoseExclude(Plugin):
|
||||||
|
|
||||||
|
@ -108,7 +116,7 @@ class NoseExclude(Plugin):
|
||||||
if abs_d:
|
if abs_d:
|
||||||
self.exclude_dirs[abs_d] = True
|
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)
|
log.debug(exclude_str)
|
||||||
|
|
||||||
def wantDirectory(self, dirname):
|
def wantDirectory(self, dirname):
|
||||||
|
@ -140,7 +148,7 @@ class NoseExclude(Plugin):
|
||||||
def wantMethod(self, meth):
|
def wantMethod(self, meth):
|
||||||
"""Filter out tests based on <module path>.<class>.<method name>"""
|
"""Filter out tests based on <module path>.<class>.<method name>"""
|
||||||
try:
|
try:
|
||||||
cls = meth.im_class # Don't test static methods
|
cls = get_method_class(meth)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
class UnitTests(unittest.TestCase):
|
class UnitTests(unittest.TestCase):
|
||||||
def test_a(self):
|
def test_a(self):
|
||||||
assert True
|
assert True
|
||||||
|
@ -7,5 +8,6 @@ class UnitTests(unittest.TestCase):
|
||||||
def test_b(self):
|
def test_b(self):
|
||||||
assert True
|
assert True
|
||||||
|
|
||||||
|
|
||||||
def test_c():
|
def test_c():
|
||||||
assert True
|
assert True
|
||||||
|
|
Loading…
Reference in New Issue