Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Fix resource leak in test_read_model_from_tensor (#36859)

Hyacinth-of-Securityf7a1b8249a9f
diff --git a/src/bindings/python/tests/test_runtime/test_core.py b/src/bindings/python/tests/test_runtime/test_core.py
index c492b112492..c06038467fa 100644
--- a/src/bindings/python/tests/test_runtime/test_core.py
+++ b/src/bindings/python/tests/test_runtime/test_core.py
@@ -169,7 +169,8 @@ def test_read_model_from_tensor(request, tmp_path):
serialize(relu_model, xml_path, bin_path)
arr = np.ones(shape=(10), dtype=np.int8)
arr.tofile(bin_path)
- model = open(xml_path).read()
+ with open(xml_path) as f:
+ model = f.read()
tensor = tensor_from_file(bin_path)
model = core.read_model(model=model, weights=tensor)
assert isinstance(model, Model)