Forked from moylop260/skip_test_from_super_class.py
Created
January 22, 2019 18:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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