Skip to content

Instantly share code, notes, and snippets.

@mdengler
Created May 14, 2014 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdengler/17cb5115f091628d1dd9 to your computer and use it in GitHub Desktop.
Save mdengler/17cb5115f091628d1dd9 to your computer and use it in GitHub Desktop.
test case for nose #711
#!/usr/bin/python
# to use:
# 1) git clone git@github.com:jszakmeister/nose.git nose-711
# 2) cd nose-711
# 3) python setup.py build
# 4) cd build/lib
# 5) put this file there as test.py
# 6) PYTHONPATH=$PWD python -m nose ./test.py
# # observe the error:
# [...]
# AttributeError: 'ContextSuite' object has no attribute 'capturedOutput'
# [...]
# 7) git checkout fix-711 # get the fix
# 8) cd ../.. ; python setup.py build ; cd - # rebuild
# 9) PYTHONPATH=$PWD python -m nose ./test.py
# # observe no more error!
# [...]
# raise ValueError() # or any other bug
# [...]
import os
from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
from nose.plugins.manager import ZeroNinePlugin
class KnownFailureTest(Exception):
pass
class KnownFailure(ErrorClassPlugin):
enabled = True
knownfail = ErrorClass(KnownFailureTest,
label='KNOWNFAIL',
isfailure=False)
def options(self, parser, env=os.environ):
pass
def configure(self, options, conf):
pass
def addError( self, test, err, *zero_nine_capt_args ):
pass
import unittest
class FooTest(unittest.TestCase):
@classmethod
def setUpClass(self):
raise ValueError() # or any other bug
def test_foo(self):
self.assertTrue(True)
import nose, sys
nose.main(argv=['-vv', '-s'], addplugins=[ZeroNinePlugin(KnownFailure())], module=sys.modules[__name__])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment