forked from siddhi/test_driven_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.py
24 lines (18 loc) · 788 Bytes
/
run_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import unittest
class AttribLoader(unittest.TestLoader):
def __init__(self, attrib):
self.attrib = attrib
def loadTestsFromModule(self, module, use_load_tests=False):
return super().loadTestsFromModule(module, use_load_tests=False)
def getTestCaseNames(self, testCaseClass):
test_names = super().getTestCaseNames(testCaseClass)
filtered_test_names = [test
for test in test_names
if hasattr(getattr(testCaseClass, test),
self.attrib)]
return filtered_test_names
if __name__ == "__main__":
loader = AttribLoader("slow")
test_suite = loader.discover(".")
runner = unittest.TextTestRunner()
runner.run(test_suite)