From 41e5301693c96f5341d0f05e5dc6fa9effd19b1e Mon Sep 17 00:00:00 2001 From: Cefn Hoile Date: Sat, 17 Feb 2018 02:02:32 +0000 Subject: [PATCH] Workaround for micropython-lib unittest module main() being buggy/unhelpful with module introspection --- python/testing/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/testing/__init__.py b/python/testing/__init__.py index e69de29..4abfca1 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -0,0 +1,14 @@ +import unittest + +def test_module(m, runner=None): + if runner is None: + runner = unittest.TestRunner() + suite = unittest.TestSuite() + for key in dir(m): + val = getattr(m, key) + try: + if issubclass(val, unittest.TestCase): + suite.addTest(val) + except: + pass + return runner.run(suite) \ No newline at end of file -- 2.49.0