Skip to content

Commit

Permalink
Added ov_version parameter to the env tests (#2209)
Browse files Browse the repository at this point in the history
### Changes

- Added `ov_version` variable for the pytest in `test_examples`;
- Added `ov_version` variable for the pytest in the `test_install_*`;

### Reason for changes

- More flexible tests

### Related tickets

- 122860

### Tests

- Updated
  • Loading branch information
KodiaqQ authored Oct 24, 2023
1 parent d879361 commit 7fcef07
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/cross_fw/examples/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def pytest_addoption(parser):
default=False,
help="If the parameter is set then the performance metrics will be tested as well",
)
parser.addoption(
"--ov_version_override", default=None, help="Parameter to set OpenVINO into the env with the version from PyPI"
)


@pytest.fixture(scope="module")
Expand All @@ -38,3 +41,8 @@ def backends_list(request):
@pytest.fixture(scope="module")
def is_check_performance(request):
return request.config.getoption("--check_performance")


@pytest.fixture(scope="module")
def ov_version_override(request):
return request.config.getoption("--ov_version_override")
16 changes: 15 additions & 1 deletion tests/cross_fw/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import os
import subprocess
from pathlib import Path
from typing import Any, Dict, List

import pytest

Expand Down Expand Up @@ -42,7 +44,14 @@ def example_test_cases():


@pytest.mark.parametrize("example_name, example_params", example_test_cases())
def test_examples(tmp_path, example_name, example_params, backends_list, is_check_performance):
def test_examples(
tmp_path: Path,
example_name: str,
example_params: Dict[str, Any],
backends_list: List[str],
is_check_performance: bool,
ov_version_override: str,
):
backend = example_params["backend"]
skip_if_backend_not_selected(backend, backends_list)
venv_path = create_venv_with_nncf(tmp_path, "pip_e_local", "venv", set([backend]))
Expand All @@ -52,6 +61,11 @@ def test_examples(tmp_path, example_name, example_params, backends_list, is_chec
run_cmd_line = f"{pip_with_venv} install -r {requirements}"
subprocess.run(run_cmd_line, check=True, shell=True)

if ov_version_override is not None:
pip_with_venv = get_pip_executable_with_venv(venv_path)
ov_version_cmd_line = f"{pip_with_venv} install {ov_version_override}"
subprocess.run(ov_version_cmd_line, check=True, shell=True)

env = os.environ.copy()
env["PYTHONPATH"] = str(PROJECT_ROOT) # need this to be able to import from tests.* in run_example.py

Expand Down
8 changes: 8 additions & 0 deletions tests/cross_fw/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def pytest_addoption(parser):
nargs="+",
default=["all"],
)
parser.addoption(
"--ov_version_override", default=None, help="Parameter to set OpenVINO into the env with the version from PyPI"
)


@pytest.fixture(scope="module")
Expand All @@ -39,3 +42,8 @@ def backend_clopt(request):
@pytest.fixture(scope="module")
def host_configuration_clopt(request):
return request.config.getoption("--host-configuration")


@pytest.fixture(scope="module")
def ov_version_override(request):
return request.config.getoption("--ov_version_override")
5 changes: 5 additions & 0 deletions tests/cross_fw/install/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ def test_install(
package_type: str,
backend_clopt: List[str],
host_configuration_clopt: str,
ov_version_override: str,
):
skip_if_backend_not_selected(backend, backend_clopt)
if "pypi" in package_type:
pytest.xfail("Disabled until NNCF is exposed in a release")
venv_path = create_venv_with_nncf(tmp_path, package_type, venv_type, extra_reqs={backend})
if ov_version_override is not None:
pip_with_venv = get_pip_executable_with_venv(venv_path)
ov_version_cmd_line = f"{pip_with_venv} install {ov_version_override}"
subprocess.run(ov_version_cmd_line, check=True, shell=True)
run_install_checks(venv_path, tmp_path, package_type, backend=backend, install_type=host_configuration_clopt)

@staticmethod
Expand Down

0 comments on commit 7fcef07

Please sign in to comment.