From 2dc91dc4a48adcf0a3b361c5b10ae58cdd2fe6ad Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Mon, 5 Jan 2026 09:20:20 +0200 Subject: [PATCH 1/2] Add test to check version --- tests/docs/test_version.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/docs/test_version.py diff --git a/tests/docs/test_version.py b/tests/docs/test_version.py new file mode 100644 index 00000000000..b2c337ad54e --- /dev/null +++ b/tests/docs/test_version.py @@ -0,0 +1,23 @@ +# Copyright (c) 2026 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re + +import nncf + + +def test_nncf_version(): + # Validate format of version + # Needed while src/custom_version.py exists + version_pattern = r"^\d\.\d{1,2}\.\d{1,2}$" # e.g., "3.0.0" + assert re.match(version_pattern, nncf.__version__), ( + f"NNCF version '{nncf.__version__}' does not match the expected pattern." + ) From 68826ebb37a13920c58563ee75c3d8dc55d83d01 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Mon, 5 Jan 2026 09:33:38 +0200 Subject: [PATCH 2/2] f --- tests/docs/test_version.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/docs/test_version.py b/tests/docs/test_version.py index b2c337ad54e..5c63480165d 100644 --- a/tests/docs/test_version.py +++ b/tests/docs/test_version.py @@ -10,14 +10,18 @@ # limitations under the License. import re +from pathlib import Path -import nncf +NNCF_VERSION_FILE = "src/nncf/version.py" def test_nncf_version(): # Validate format of version # Needed while src/custom_version.py exists + version = re.search(r"^__version__ = ['\"](.*)['\"]", Path(NNCF_VERSION_FILE).read_text(), re.M) + assert version, f"Cannot find version in {NNCF_VERSION_FILE}" + version_str = version.group(1) version_pattern = r"^\d\.\d{1,2}\.\d{1,2}$" # e.g., "3.0.0" - assert re.match(version_pattern, nncf.__version__), ( - f"NNCF version '{nncf.__version__}' does not match the expected pattern." + assert re.match(version_pattern, version_str), ( + f"NNCF version '{version}' in {NNCF_VERSION_FILE} does not match the expected pattern." )