From a65cfe58a84461329db65f8fa2b2c22ed00f97d0 Mon Sep 17 00:00:00 2001 From: Stanislav Zubov Date: Thu, 15 Feb 2018 14:59:26 +0700 Subject: [PATCH] plugin-class-skipper (#31) --- CHANGELOG.md | 4 ++++ lode_runner/core.py | 7 ++++++- lode_runner/plugins/class_skipper.py | 17 +++++++++++++++++ setup.py | 5 +++-- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 lode_runner/plugins/class_skipper.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f5da206..34a3ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.3 + +- Add XUnit plugin 'lode_runner.plugins.ClassSkipper'. Allows skip TestClasses with no setUpClass calls + ## 0.4.2 - Skip 'nose.multiprocess' testcases dirung merging xml files diff --git a/lode_runner/core.py b/lode_runner/core.py index d8a891a..79b05f1 100644 --- a/lode_runner/core.py +++ b/lode_runner/core.py @@ -112,9 +112,10 @@ def plugins(): from lode_runner.plugins.testid import TestId from lode_runner.plugins.initializer import Initializer from lode_runner.plugins.failer import Failer + from lode_runner.plugins.class_skipper import ClassSkipper plugs = [ - Dataprovider, Xunit, MultiProcess, TestId, Initializer, Failer + Dataprovider, Xunit, MultiProcess, TestId, Initializer, Failer, ClassSkipper ] from nose.plugins import builtin @@ -143,3 +144,7 @@ def run(*args, **kwargs): except KeyError: argv = ['run'] return LodeProgram(argv=argv, *args, **kwargs).success + + +if __name__ == "__main__": + main() diff --git a/lode_runner/plugins/class_skipper.py b/lode_runner/plugins/class_skipper.py new file mode 100644 index 0000000..004b46e --- /dev/null +++ b/lode_runner/plugins/class_skipper.py @@ -0,0 +1,17 @@ +# coding: utf-8 + +from nose.plugins import Plugin +from nose.exc import SkipTest + + +class ClassSkipper(Plugin): + name = 'class_skipper' + enabled = True + + def configure(self, options, conf): + super(ClassSkipper, self).configure(options, conf) + self.enabled = True + + def startContext(self, context): + if getattr(context, '__unittest_skip__', False): + raise SkipTest(getattr(context, '__unittest_skip_why__', 'Unknown skip reason')) diff --git a/setup.py b/setup.py index 3e3e6b4..df98bb7 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='lode_runner', url='https://github.com/2gis/lode_runner', - version='0.4.2', + version='0.4.3', description='Nosetests runner plugins package', long_description='', author='Igor Pavlov', @@ -25,7 +25,8 @@ 'multiprocess = lode_runner.plugins.multiprocess:MultiProcess', 'testid = lode_runner.plugins.testid:TestId', 'initializer = lode_runner.plugins.initializer:Initializer', - 'failer = lode_runner.plugins.failer:Failer' + 'failer = lode_runner.plugins.failer:Failer', + 'class_skipper = lode_runner.plugins.class_skipper:ClassSkipper' ] }, classifiers=[