Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yasmanycastillo/58a92fec442b04832a4fe7b11652f530 to your computer and use it in GitHub Desktop.
Save yasmanycastillo/58a92fec442b04832a4fe7b11652f530 to your computer and use it in GitHub Desktop.
How to skip a method test from a inherited test class for python
class TestCustom(Test):
def __init__(self, methodName='runTest'):
super(TestCustom, self).__init__(methodName)
# Skip original test from inherited class
custom_attributes = set(dir(TestCustom)) - set(dir(Test))
custom_test_methods = [
name for name in custom_attributes
if name.startswith('test_') and callable(getattr(self, name))]
if methodName not in custom_test_methods:
method = getattr(self, methodName)
method.__dict__['__unittest_skip__'] = True
method.__dict__['__unittest_skip_why__'] = (
'Test executed from original module')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment