convert all test_caller*.py to work with pytest/unittest test discovery
[openpower-isa.git] / src / openpower / decoder / isa / test_caller_svp64_utf_8_validation.py
index 37fbdf41c7cc71f92caf57d29126ce5f9c6a6f66..de86dfb064e7dcb9ec6beb10a16157b08780b8cf 100644 (file)
@@ -1,39 +1,23 @@
-""" Decoder tests
-
-related bugs:
-
- *
-"""
+# SPDX-License-Identifier: LGPL-3-or-later
+# Copyright 2022 Jacob Lifshay
 
 import unittest
-import sys
-
-# These tests utilize the run_hdl=False parameter to compare
-# simulator with expected states
-from soc.simple.test.test_runner import TestRunner
 from openpower.test.algorithms.svp64_utf_8_validation import \
     SVP64UTF8ValidationTestCase
+from openpower.test.runner import TestRunnerBase
 
+# 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]
+class TestSVP64UTF8Validation(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(SVP64UTF8ValidationTestCase().test_data)
 
-    if not testing:
-        testing = ['utf-8_validation']
+    def test(self):
+        # dummy function to make unittest try to test this class
+        pass
 
-    unittest.main(exit=False)
-    suite = unittest.TestSuite()
 
-    # dictionary of data for tests
-    tests = {'utf-8_validation': SVP64UTF8ValidationTestCase().test_data}
-
-    # walk through all tests, those requested get added
-    for tname, data in tests.items():
-        if tname in testing:
-            suite.addTest(TestRunner(data, run_hdl=False))
-
-    runner = unittest.TextTestRunner()
-    runner.run(suite)
+if __name__ == "__main__":
+    unittest.main()