convert all test_caller*.py to work with pytest/unittest test discovery
[openpower-isa.git] / src / openpower / decoder / isa / test_caller_logical.py
index 9546319f4f66c9149833195d2c251e863b50f907..9293cd0390f9d757e4077fee3a25e1e4d3dba851 100644 (file)
@@ -6,33 +6,21 @@ related bugs:
 """
 
 import unittest
-import sys
-
-# These tests utilize the run_hdl=False parameter to compare
-# simulator with expected states
 from openpower.test.runner import TestRunnerBase
 from openpower.test.logical.logical_cases import LogicalTestCase
 
+# writing the test_caller invocation this way makes it work with pytest
 
-if __name__ == "__main__":
-
-    # allow list of testing to be selected by command-line
-    testing = sys.argv[1:]
-    sys.argv = sys.argv[:1]
 
-    if not testing:
-        testing = ['logical']
+class TestLogical(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(LogicalTestCase().test_data)
 
-    unittest.main(exit=False)
-    suite = unittest.TestSuite()
+    def test(self):
+        # dummy function to make unittest try to test this class
+        pass
 
-    # dictionary  of data for tests
-    tests = {'logical': LogicalTestCase().test_data}
 
-    # walk through all tests, those requested get added
-    for tname, data in tests.items():
-        if tname in testing:
-            suite.addTest(TestRunnerBase(data))
-
-    runner = unittest.TextTestRunner()
-    runner.run(suite)
+if __name__ == "__main__":
+    unittest.main()