Skip to content

Instantly share code, notes, and snippets.

@generalov
Last active August 29, 2015 13:56
Show Gist options
  • Save generalov/9271116 to your computer and use it in GitHub Desktop.
Save generalov/9271116 to your computer and use it in GitHub Desktop.
"""
Usage
-----
>>> class TestTodo(unittest.TestCase):
... def runTest(self):
... raise Todo("I need to test something")
Configuration
-------------
With python setup.py test
-------------------------
Step 1: Tell nose how to find the plugin.
Example::
setup(
entry_points={
'nose.plugins': [
'todo = tests.support.errorclass_failure_plugin:TodoPlugin',
'non-failure-todo = tests.support.errorclass_failure_plugin:NonFailureTodoPlugin',
]
},
test_suite = 'nose.collector',
tests_require=['nose'],
)
Step 2: Enable todo or non-failure-todo plugin in setup.cfg.
Example::
[nosetests]
with-todo=1
Thanks to
---------
http://nose.readthedocs.org/en/latest/plugins/errorclasses.html
http://nose.readthedocs.org/en/latest/doc_tests/test_issue142/errorclass_failure.html
https://pypi.python.org/pypi/Nose-PyVersion
"""
from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin as ErrorClassPlugin_
class ErrorClassPlugin(ErrorClassPlugin_):
# XXX: https://github.com/nose-devs/nose/issues/467
def addError(self, test, err, capt=None):
return super(ErrorClassPlugin, self).addError(test, err)
class Todo(Exception):
pass
class TodoPlugin(ErrorClassPlugin):
name = "todo"
todo = ErrorClass(Todo, label='TODO', isfailure=True)
class NonFailureTodoPlugin(ErrorClassPlugin):
name = "non-failure-todo"
todo = ErrorClass(Todo, label='TODO', isfailure=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment