From 626ad335264b21749c2985d3d1fc7556975f5d56 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 20 Feb 2024 13:50:08 -0600 Subject: [PATCH] New pytest version dependency tweaks (#681) Fixups to #656 by switching to a new plugin and alerting to remove the old one. Includes changes from #680 --------- Co-authored-by: Sergiy Matusevych --- conda-envs/mlos-3.10.yml | 1 - conda-envs/mlos-3.11.yml | 1 - conda-envs/mlos-3.8.yml | 1 - conda-envs/mlos-3.9.yml | 1 - conda-envs/mlos-windows.yml | 1 - conda-envs/mlos.yml | 1 - .../mlos_bench/tests/event_loop_context_test.py | 2 +- .../services/remote/ssh/test_ssh_service.py | 16 ++++++++++++++-- mlos_bench/setup.py | 4 ++-- mlos_core/mlos_core/tests/spaces/__init__.py | 7 +++++++ 10 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 mlos_core/mlos_core/tests/spaces/__init__.py diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index dad480d2fbb..fc47df4f92c 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -32,7 +32,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index 3e7590a562d..8bed104cfae 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -32,7 +32,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 8360168837c..3cfe74dbf4a 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -32,7 +32,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index 2ac95f127fd..a47ee84914e 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -32,7 +32,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index 13089222e75..dcb1bc930e8 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -36,7 +36,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index 445832f8747..278a0dbe25e 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -30,7 +30,6 @@ dependencies: - types-colorama - types-jsonschema - types-pygments - - types-pytest-lazy-fixture - types-requests - types-setuptools - "--editable ../mlos_core[full-tests]" diff --git a/mlos_bench/mlos_bench/tests/event_loop_context_test.py b/mlos_bench/mlos_bench/tests/event_loop_context_test.py index e3e4d2ef9ac..80b252f255c 100644 --- a/mlos_bench/mlos_bench/tests/event_loop_context_test.py +++ b/mlos_bench/mlos_bench/tests/event_loop_context_test.py @@ -127,7 +127,7 @@ def test_event_loop_context() -> None: assert hasattr(EventLoopContextCaller.EVENT_LOOP_CONTEXT._event_loop, '_scheduled') assert len(EventLoopContextCaller.EVENT_LOOP_CONTEXT._event_loop._scheduled) == 0 - with pytest.raises(AssertionError), pytest.warns(RuntimeWarning, match=r".*coroutine 'sleep' was never awaited"): + with pytest.raises(AssertionError): # , pytest.warns(RuntimeWarning, match=r".*coroutine 'sleep' was never awaited"): future = event_loop_caller_instance_1.EVENT_LOOP_CONTEXT.run_coroutine(asyncio.sleep(0.1, result='foo')) raise ValueError(f"Future should not have been available to wait on {future.result()}") diff --git a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_service.py b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_service.py index 16b04dd407c..fd0804ba158 100644 --- a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_service.py +++ b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_service.py @@ -7,13 +7,14 @@ """ import asyncio +from importlib.metadata import version, PackageNotFoundError import time from subprocess import run from threading import Thread import pytest -from pytest_lazyfixture import lazy_fixture +from pytest_lazy_fixtures.lazy_fixture import lf as lazy_fixture from mlos_bench.services.remote.ssh.ssh_service import SshService from mlos_bench.services.remote.ssh.ssh_host_service import SshHostService @@ -23,6 +24,17 @@ from mlos_bench.tests.services.remote.ssh import SshTestServerInfo, ALT_TEST_SERVER_NAME, SSH_TEST_SERVER_NAME +if version("pytest") >= "8.0.0": + try: + # We replaced pytest-lazy-fixture with pytest-lazy-fixtures: + # https://github.com/TvoroG/pytest-lazy-fixture/issues/65 + if version("pytest-lazy-fixture"): + raise UserWarning("pytest-lazy-fixture conflicts with pytest>=8.0.0. Please remove it.") + except PackageNotFoundError: + # OK: pytest-lazy-fixture not installed + pass + + @requires_docker @requires_ssh @pytest.mark.parametrize(["ssh_test_server_info", "server_name"], [ @@ -91,7 +103,7 @@ def test_ssh_service_context_handler() -> None: assert not ssh_fileshare_service._in_context # And that instance should be unusable after we are outside the context. - with pytest.raises(AssertionError), pytest.warns(RuntimeWarning, match=r".*coroutine 'sleep' was never awaited"): + with pytest.raises(AssertionError): # , pytest.warns(RuntimeWarning, match=r".*coroutine 'sleep' was never awaited"): future = ssh_fileshare_service._run_coroutine(asyncio.sleep(0.1, result='foo')) raise ValueError(f"Future should not have been available to wait on {future.result()}") diff --git a/mlos_bench/setup.py b/mlos_bench/setup.py index 24573589d8f..d1fd3a9d3bf 100644 --- a/mlos_bench/setup.py +++ b/mlos_bench/setup.py @@ -75,12 +75,12 @@ def _get_long_desc_from_readme(base_url: str) -> dict: extra_requires['full'] = list(set(chain(*extra_requires.values()))) extra_requires['full-tests'] = extra_requires['full'] + [ - 'pytest<8.0.0', # FIXME: https://github.com/TvoroG/pytest-lazy-fixture/issues/65 + 'pytest', 'pytest-forked', 'pytest-xdist', 'pytest-cov', 'pytest-local-badge', - 'pytest-lazy-fixture', + 'pytest-lazy-fixtures', 'pytest-docker', 'fasteners', ] diff --git a/mlos_core/mlos_core/tests/spaces/__init__.py b/mlos_core/mlos_core/tests/spaces/__init__.py new file mode 100644 index 00000000000..489802cb5af --- /dev/null +++ b/mlos_core/mlos_core/tests/spaces/__init__.py @@ -0,0 +1,7 @@ +# +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# +""" +Basic initializer module for the mlos_core.tests.spaces package. +"""