Files
openvino/src/bindings/python/tests/test_utils/test_utils.py
T
Anastasia Kuporosova 23cad1770e [PyOV] clean up in tests (#19091)
* [PyOV] clean up in tests

* use generated model in tests

* fix ci

* return back fild

* fix ci 1

* fix ci2

* update

* move models

* return back deleted test

* move model creation from conftest

* fix ci

* fix ci
2023-08-30 13:40:14 +02:00

61 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from openvino.utils import deprecated
from tests.utils.helpers import compare_models, get_relu_model
def test_compare_functions():
try:
from openvino.test_utils import compare_functions
model = get_relu_model()
status, _ = compare_functions(model, model)
assert status
except RuntimeError:
print("openvino.test_utils.compare_functions is not available") # noqa: T201
def test_compare_models_pass():
model = get_relu_model()
assert compare_models(model, model)
def test_compare_models_fail():
model = get_relu_model()
changed_model = model.clone()
changed_model.get_ordered_ops()[0].set_friendly_name("ABC")
with pytest.raises(RuntimeError) as e:
_ = compare_models(model, changed_model)
assert "Not equal op names model_one: data, model_two: ABC." in str(e.value)
def test_deprecation_decorator():
@deprecated()
def deprecated_function1(param1, param2=None):
pass
@deprecated(version="2025.4")
def deprecated_function2(param1=None):
pass
@deprecated(message="Use another function instead")
def deprecated_function3():
pass
@deprecated(version="2025.4", message="Use another function instead")
def deprecated_function4():
pass
with pytest.warns(DeprecationWarning, match="deprecated_function1 is deprecated"):
deprecated_function1("param1")
with pytest.warns(DeprecationWarning, match="deprecated_function2 is deprecated and will be removed in version 2025.4"):
deprecated_function2(param1=1)
with pytest.warns(DeprecationWarning, match="deprecated_function3 is deprecated. Use another function instead"):
deprecated_function3()
with pytest.warns(DeprecationWarning, match="deprecated_function4 is deprecated and will be removed in version 2025.4. Use another function instead"):
deprecated_function4()