Skip to content
Snippets Groups Projects
Commit 00b457e6 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Added result check

parent c1962b22
No related branches found
No related tags found
1 merge request!51Improve export
Pipeline #74964 failed
......@@ -9,20 +9,20 @@ EXAMPLES_DIR = CURRENT_DIR / "../../examples"
# Dictionary of test cases: {id: (script_name, script_args)}
TEST_CASES = {
"lenet-no-args": ("export_LeNet/lenet.py", []),
"lenet-int8": ("export_LeNet/lenet.py", ["--dtype=int8"]),
"resnet18-no-args": ("export_ResNet18/resnet18.py", ["--mock_db"]),
"resnet18-int8": ("export_ResNet18/resnet18.py", ["--mock_db", "--dtype=int8"])
"lenet-no-args": ("export_LeNet/lenet.py", [], ["MODEL ACCURACY = 100.0 %", "Prediction out#0: 7 (1)"]),
"lenet-int8": ("export_LeNet/lenet.py", ["--dtype=int8"], ["MODEL ACCURACY = 100.0 %", "MODEL ACCURACY = 100.0 %", "QUANTIZED ACCURACY = 100.0 %", "Prediction out#0: 7 (119)"]),
"resnet18-no-args": ("export_ResNet18/resnet18.py", ["--mock_db"], []),
"resnet18-int8": ("export_ResNet18/resnet18.py", ["--mock_db", "--dtype=int8"], [])
}
def generate_test_cases():
"""Parse TEST_CASES to provide valid pytest params.
"""
for test_id, (script, args) in TEST_CASES.items():
yield pytest.param(script, args, id=test_id)
for test_id, (script, args, result) in TEST_CASES.items():
yield pytest.param(script, args, result, id=test_id)
@pytest.mark.parametrize(("script_name", "script_args"), generate_test_cases())
def test_example_scripts_run_without_error(script_name, script_args):
@pytest.mark.parametrize(("script_name", "script_args", "script_result"), generate_test_cases())
def test_example_scripts_run_without_error(script_name, script_args, script_result):
"""Basic test to verify that examples script run withoput raising an Error.
This test DO NOT check that the examples are working only that they are not broken.
"""
......@@ -34,6 +34,9 @@ def test_example_scripts_run_without_error(script_name, script_args):
)
assert result.returncode == 0, f"{script_name} failed with error:\n{result.stderr}\n\nTraceback:\n{result.stdout}"
for res in script_result:
assert res in result.stdout, f"Expected output '{res}' not found in the script output:\n{result.stdout}"
def main():
import sys
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment