convert all test_caller*.py to work with pytest/unittest test discovery
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 25 Aug 2022 05:33:51 +0000 (22:33 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 25 Aug 2022 05:33:51 +0000 (22:33 -0700)
all the removed code had no benefit because each file only tested
one *TestCase* class, the removed code was only useful for
selecting between multiple *TestCase* classes

src/openpower/decoder/isa/test_caller_alu.py
src/openpower/decoder/isa/test_caller_bitmanip.py
src/openpower/decoder/isa/test_caller_bitmanip_av.py
src/openpower/decoder/isa/test_caller_fmvis.py
src/openpower/decoder/isa/test_caller_logical.py
src/openpower/decoder/isa/test_caller_mul.py
src/openpower/decoder/isa/test_caller_shift_rot.py
src/openpower/decoder/isa/test_caller_svp64_alu.py
src/openpower/decoder/isa/test_caller_svp64_logical.py
src/openpower/decoder/isa/test_caller_svp64_utf_8_validation.py

index 9011ef62cb878cfe848b5838c0092b54c7fc2e5a..9aef6f2af5006b31b384180b1d438131df21a10f 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.alu.alu_cases import ALUTestCase
 
+# 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 = ['alu']
+class TestALU(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(ALUTestCase().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 = {'alu': ALUTestCase().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()
index 6ba5f661885083e9aa0a7ff394e0f270232dce57..15e2c0a42e5d0d94c8e8151aefb83237fe3a01d8 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.bitmanip.bitmanip_cases import BitManipTestCase
 
+# 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 = ['bitmanip']
+class TestBitManip(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(BitManipTestCase().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 = {'bitmanip': BitManipTestCase().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()
index 4e5cf97a9f259661a42672733375732c1415a1d7..803d71684f4f8bb746f8b110d02c93347078a1bf 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.bitmanip.av_cases import AVTestCase
 
+# 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 = ['bitmanipav']
+class TestAV(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(AVTestCase().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 = {'bitmanipav': AVTestCase().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()
index 1c7638a4c8e1583c5bdaa57728e3aca04eb3ae9f..6a71522bfb76f2726e06f6517ea82ce3507531b7 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.alu.fmvis_cases import FMVISTestCase
 
+# 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 = ['fmvis', 'fishmv']
+class TestFMVIS(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(FMVISTestCase().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 = {'fmvis': FMVISTestCase().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()
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()
index 824d3a93f2cf4f1b620c30e8ccefc36b07090d78..24b2f00de8fcae49fc2366c24e0aed990048f68f 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.mul.mul_cases import MulTestCases2Arg
 
+# 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 = ['mul2']
+class TestMul2Arg(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(MulTestCases2Arg().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 = {'mul2': MulTestCases2Arg().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()
index 6d0a949f274c0d50303aeda4687d1de116fdfa90..90bd328bfbfcf90d46d24ba9d9a5b03ed2caed18 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.shift_rot.shift_rot_cases2 import ShiftRotTestCase2
 
+# 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 = ['shiftrot2']
+class TestShiftRot2(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(ShiftRotTestCase2().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 = {'shiftrot2': ShiftRotTestCase2().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()
index 1a294d5decdf4223d3dccf7d4014260ac50e3a5e..5b10bead3336fd688d6b3a4540b0fdb9fbaf71cc 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.alu.svp64_cases import SVP64ALUTestCase
 
+# 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 = ['svp64_alu']
+class TestSVP64ALU(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(SVP64ALUTestCase().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 = {'svp64_alu': SVP64ALUTestCase().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()
index bc600cf739f8afd181ae32a8e83162f6920e6a32..b98ebeb33d814202ddd31aacfbe301f3c046c3af 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.svp64_cases import SVP64LogicalTestCase
 
+# 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 = ['svp64_logical']
+class TestSVP64Logical(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(SVP64LogicalTestCase().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 = {'svp64_logical': SVP64LogicalTestCase().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()
index e14b12c5d03acba30be5bfe37610e12f19da41f2..de86dfb064e7dcb9ec6beb10a16157b08780b8cf 100644 (file)
@@ -8,6 +8,7 @@ from openpower.test.runner import TestRunnerBase
 
 # writing the test_caller invocation this way makes it work with pytest
 
+
 class TestSVP64UTF8Validation(TestRunnerBase):
     def __init__(self, test):
         assert test == 'test'