Skip to content

Commit e267705

Browse files
ytl0623pre-commit-ci[bot]KumoLiu
authored
Added an optional_import check for onnxruntime and applied the @unitt… (#8641)
…est.skipUnless decorator to the test_onnx method. Fixes #8533 . ### Description Added an optional_import check for onnxruntime and applied the @unittest.skipUnless decorator to the test_onnx method. This ensures the ONNX tests are automatically skipped if the onnxruntime dependency is missing, preventing the test suite from hanging. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: ytl0623 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: YunLiu <[email protected]>
1 parent 04a89ee commit e267705

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/apps/detection/networks/test_retinanet.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from tests.test_utils import dict_product, skip_if_quick, test_onnx_save, test_script_save
2424

2525
_, has_torchvision = optional_import("torchvision")
26+
_, has_onnxruntime = optional_import("onnxruntime")
2627

2728
device = "cuda" if torch.cuda.is_available() else "cpu"
2829
num_anchors = 7
@@ -169,6 +170,7 @@ def test_script(self, model, input_param, input_shape):
169170
test_script_save(net, data)
170171

171172
@parameterized.expand(TEST_CASES_TS)
173+
@unittest.skipUnless(has_onnxruntime, "onnxruntime not installed")
172174
def test_onnx(self, model, input_param, input_shape):
173175
try:
174176
idx = int(self.id().split("test_onnx_")[-1])

0 commit comments

Comments
 (0)