From c58603405ab101d707626306d9e4e5e646b85036 Mon Sep 17 00:00:00 2001 From: Vinayak Dev Date: Fri, 15 Nov 2024 00:48:54 +0530 Subject: [PATCH] Move externalization tests in test file --- .../python/test/tools/import_onnx_test.py | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/compiler/bindings/python/test/tools/import_onnx_test.py b/compiler/bindings/python/test/tools/import_onnx_test.py index 5c797e9be281..6089b65ef057 100644 --- a/compiler/bindings/python/test/tools/import_onnx_test.py +++ b/compiler/bindings/python/test/tools/import_onnx_test.py @@ -27,6 +27,30 @@ def run_tool(*argv: str): ) +class ImportOnnxTest(unittest.TestCase): + def setUp(self): + with tempfile.NamedTemporaryFile(delete=False) as f: + self.outputPath = f.name + + def tearDown(self) -> None: + if os.path.exists(self.outputPath): + os.unlink(self.outputPath) + + def testConsoleOutput(self): + # Just test that it doesn't crash: rely on the file test for verification. + run_tool(ONNX_FILE_PATH) + + def testDisableVerify(self): + # Just test that the flag is accepted. + run_tool(ONNX_FILE_PATH, "--no-verify") + + def testFileOutput(self): + run_tool(ONNX_FILE_PATH, "-o", self.outputPath) + with open(self.outputPath, "rt") as f: + contents = f.read() + self.assertIn("torch.operator", contents) + + class ImportOnnxwithExternalizationTest(unittest.TestCase): def setUp(self): with tempfile.NamedTemporaryFile(delete=False) as f: @@ -102,30 +126,6 @@ def testExternalizeMinimumThreshold(self): self.assertNotIn("onnx.Constant", contents) -class ImportOnnxTest(unittest.TestCase): - def setUp(self): - with tempfile.NamedTemporaryFile(delete=False) as f: - self.outputPath = f.name - - def tearDown(self) -> None: - if os.path.exists(self.outputPath): - os.unlink(self.outputPath) - - def testConsoleOutput(self): - # Just test that it doesn't crash: rely on the file test for verification. - run_tool(ONNX_FILE_PATH) - - def testDisableVerify(self): - # Just test that the flag is accepted. - run_tool(ONNX_FILE_PATH, "--no-verify") - - def testFileOutput(self): - run_tool(ONNX_FILE_PATH, "-o", self.outputPath) - with open(self.outputPath, "rt") as f: - contents = f.read() - self.assertIn("torch.operator", contents) - - if __name__ == "__main__": try: import onnx