Skip to content

Commit 54c5bce

Browse files
committed
functionality for running unit tests
1 parent 8e33b97 commit 54c5bce

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

python/code/wypp/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ def record(cls=None, mutable=False, globals={}, locals={}):
6969
# Exported names not available for star imports (in alphabetic order)
7070
Lock = w.Lock
7171
LockFactory = w.LockFactory
72+
deepEq = w.deepEq
7273
initModule = w.initModule
7374
printTestResults = w.printTestResults
7475
resetTestCount = w.resetTestCount
75-
deepEq = w.deepEq
76+
runUnittests = w.runUnittests
7677
wrapTypecheck = w.wrapTypecheck
7778
WyppTypeError = w.WyppTypeError
7879
WyppAttributeError = w.WyppAttributeError

python/code/wypp/writeYourProgram.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ def impossible(msg=None):
317317
'Das Unmögliche ist passiert!'
318318
raise errors.ImpossibleError(msg)
319319

320+
def runUnittests(scope: dict[str, Any]):
321+
import unittest
322+
suite = unittest.TestSuite()
323+
loader = unittest.TestLoader()
324+
for item in scope.values():
325+
if isinstance(item, type) and issubclass(item, unittest.TestCase):
326+
if item is not unittest.TestCase:
327+
suite.addTest(loader.loadTestsFromTestCase(item))
328+
unittest.TextTestRunner(verbosity=2).run(suite)
329+
320330
# Additional functions and aliases
321331

322332
import math as moduleMath

0 commit comments

Comments
 (0)