From f8ad6b1111e3927ecfaafd26f6952745c4b8df0c Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sat, 29 Aug 2015 17:44:18 -0700 Subject: [PATCH 1/2] return None from wantMethod --- nose_exclude.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nose_exclude.py b/nose_exclude.py index c5a3ac7..396c28e 100644 --- a/nose_exclude.py +++ b/nose_exclude.py @@ -150,7 +150,7 @@ class NoseExclude(Plugin): try: cls = get_method_class(meth) except AttributeError: - return False + return None fqn = '%s.%s.%s' % (cls.__module__, cls.__name__, meth.__name__) if fqn in self.exclude_tests: From 6322586b14437a4211811dc404627e161962fbbc Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Wed, 27 Apr 2016 14:12:53 +0200 Subject: [PATCH 2/2] test AssertionError from get_method_class --- tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests.py b/tests.py index 864062e..688daea 100644 --- a/tests.py +++ b/tests.py @@ -224,5 +224,28 @@ class TestNoseExcludeTestModule(PluginTester, unittest.TestCase): def test_tests_excluded(self): assert 'Ran 3 tests' in self.output + +class TestNoseDoesNotExcludeTestClass(PluginTester, unittest.TestCase): + """Test nose-exclude tests by class""" + + activate = "--exclude-test=test_dirs.unittest.test" + plugins = [NoseExclude()] + suitepath = os.path.join(os.getcwd(), 'test_dirs/unittest') + + def setUp(self): + def mock_get_method_class(meth): + raise AttributeError('foobar') + import nose_exclude + self.old_get_method_class = nose_exclude.get_method_class + nose_exclude.get_method_class = mock_get_method_class + super(TestNoseDoesNotExcludeTestClass, self).setUp() + + def tearDown(self): + import nose_exclude + nose_exclude.get_method_class = self.old_get_method_class + + def test_tests_not_excluded(self): + assert 'Ran 3 tests' in self.output + if __name__ == '__main__': unittest.main()