Skip to content

Instantly share code, notes, and snippets.

@juliomfreitas
Last active October 22, 2016 03:10
Show Gist options
  • Save juliomfreitas/b06d92983d7697a746696613e6e36771 to your computer and use it in GitHub Desktop.
Save juliomfreitas/b06d92983d7697a746696613e6e36771 to your computer and use it in GitHub Desktop.
how to use a test with expecting failure
class NotImplementedToExpectedFailure:
def run(self, result=None):
# Override the run method to inject the "expectingFailure" marker
# when the test case runs.
if self._testMethodName in getattr(self, 'not_implemented', []):
# Mark 'expecting failure' on class. It will only be applicable
# for this specific run.
method = getattr(self, self._testMethodName)
wrapper = lambda *args, **kwargs: method(*args, **kwargs)
wrapper.__unittest_expecting_failure__ = True
setattr(self, self._testMethodName, wrapper)
return super().run(result=result)
class BinaryBoolOperationTests(NotImplementedToExpectedFailure):
not_implemented = [
'test_add_class'
]
def test_add_class(self):
pass
def test_add_complex(self):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment