@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+import functools
import sys
import unittest
@@ -43,9 +44,15 @@ class LavaTestResult(unittest.TextTestResult):
self.writeLavaSignal(test, "skip")
+class LavaTestRunner(unittest.TextTestRunner):
+ __init__ = functools.partialmethod(
+ unittest.TextTestRunner.__init__,
+ resultclass=LavaTestResult)
+
+
if __name__ == "__main__":
unittest.main(
- testRunner=unittest.TextTestRunner(resultclass=LavaTestResult),
+ testRunner=LavaTestRunner,
# these make sure that some options that are not applicable
# remain hidden from the help menu.
failfast=False,
testRunner in unittest.main() shouldn't be an instance. Otherwise, any verbosity flag won't pass into the testRunner. For example: 1. m = unittest.main( testRunner=TextTestRunner(...), verbosity=0 ) The verbosity won't take effect in the TextTestRunner. Instead, it uses the default verbosity in TextTestRunner(), i.e., 1. 2. m = unittest.main( testRunner=TextTestRunner(...), ) When invoking `python3 -m ... -q`, it intends to set the verbosity to 0. However, the testRunner has been instantiated, the flag won't pass to the testRunner. Thus, LavaTestRunner is back. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> --- cros/runners/lava_runner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)