Skip to content

Instantly share code, notes, and snippets.

@knil-sama
Created February 14, 2018 13:50
Show Gist options
  • Save knil-sama/95afeb99ab6dad6d34ab596c71317732 to your computer and use it in GitHub Desktop.
Save knil-sama/95afeb99ab6dad6d34ab596c71317732 to your computer and use it in GitHub Desktop.
Automated test suite in python unittest
import unittest
from tests.test_aggregation_logic import AggregationLogicTestCase
from tests.test_api_mock import TestApi
from tests.test_commons import CommonsTestCase
def listing_test_class(suite: unittest.TestSuite, test_class):
[suite.addTest(test_class(func)) for func in dir(test_class) if func.startswith("test_")]
return suite
def suite():
suite = unittest.TestSuite()
suite = listing_test_class(suite, AggregationLogicTestCase)
suite = listing_test_class(suite, TestApi)
suite = listing_test_class(suite, CommonsTestCase)
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
test_suite = suite()
runner.run(test_suite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment