Skip to content

Commit

Permalink
New pytest version dependency tweaks (#681)
Browse files Browse the repository at this point in the history
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 <sergiym@microsoft.com>
  • Loading branch information
bpkroth and motus authored Feb 20, 2024
1 parent dfebc91 commit 626ad33
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
1 change: 0 additions & 1 deletion conda-envs/mlos-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 0 additions & 1 deletion conda-envs/mlos-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 0 additions & 1 deletion conda-envs/mlos-3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 0 additions & 1 deletion conda-envs/mlos-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 0 additions & 1 deletion conda-envs/mlos-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 0 additions & 1 deletion conda-envs/mlos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/tests/event_loop_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"], [
Expand Down Expand Up @@ -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()}")

Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand Down
7 changes: 7 additions & 0 deletions mlos_core/mlos_core/tests/spaces/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
"""
Basic initializer module for the mlos_core.tests.spaces package.
"""

0 comments on commit 626ad33

Please sign in to comment.