From 4ca61ba11aefe82f470cc35b2169c28d4ed45198 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sat, 9 Dec 2023 19:17:31 +0800 Subject: [PATCH] tests: fix for pytest-asyncio 0.23 --- tests/conftest.py | 15 +++------------ tests/test_alpm.py | 2 +- tests/test_alpmfiles.py | 2 +- tests/test_android_sdk.py | 2 +- tests/test_anitya.py | 2 +- tests/test_apt.py | 2 +- tests/test_archpkg.py | 2 +- tests/test_aur.py | 2 +- tests/test_bitbucket.py | 2 +- tests/test_cache.py | 2 +- tests/test_cmd.py | 2 +- tests/test_combiner.py | 2 +- tests/test_container.py | 2 +- tests/test_cpan.py | 2 +- tests/test_cran.py | 2 +- tests/test_cratesio.py | 2 +- tests/test_debianpkg.py | 2 +- tests/test_gems.py | 2 +- tests/test_git.py | 2 +- tests/test_gitea.py | 2 +- tests/test_github.py | 2 +- tests/test_gitlab.py | 2 +- tests/test_hackage.py | 2 +- tests/test_htmlparser.py | 2 +- tests/test_httpheader.py | 2 +- tests/test_manual.py | 2 +- tests/test_npm.py | 2 +- tests/test_openvsx.py | 2 +- tests/test_packagist.py | 2 +- tests/test_pacman.py | 2 +- tests/test_pagure.py | 2 +- tests/test_pypi.py | 2 +- tests/test_regex.py | 2 +- tests/test_repology.py | 2 +- tests/test_sparkle.py | 2 +- tests/test_substitute.py | 2 +- tests/test_ubuntupkg.py | 2 +- tests/test_vsmarketplace.py | 2 +- 38 files changed, 40 insertions(+), 49 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 17b4b2e..693b125 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,7 +50,7 @@ async def run( vers, _has_failures = await main.run(result_coro, runner_coro) return vers -@pytest_asyncio.fixture(scope="module") +@pytest_asyncio.fixture(scope="session") async def get_version(): async def __call__(name, config): entries = {name: config} @@ -59,7 +59,7 @@ async def get_version(): return __call__ -@pytest_asyncio.fixture(scope="module") +@pytest_asyncio.fixture(scope="session") async def run_str(): async def __call__(str): entries = tomllib.loads(str) @@ -68,7 +68,7 @@ async def run_str(): return __call__ -@pytest_asyncio.fixture(scope="module") +@pytest_asyncio.fixture(scope="session") async def run_str_multi(): async def __call__(str): entries = tomllib.loads(str) @@ -77,15 +77,6 @@ async def run_str_multi(): return __call__ -loop = asyncio.new_event_loop() -@pytest.fixture(scope="session") -def event_loop(request): - """Override pytest-asyncio's event_loop fixture, - Don't create an instance of the default event loop for each test case. - We need the same ioloop across tests for the aiohttp support. - """ - yield loop - @pytest.fixture(scope="session", autouse=True) def raise_on_logger_msg(): def proc(logger, method_name, event_dict): diff --git a/tests/test_alpm.py b/tests/test_alpm.py index 870d061..862dda0 100644 --- a/tests/test_alpm.py +++ b/tests/test_alpm.py @@ -9,7 +9,7 @@ import tempfile import pytest pytestmark = [ - pytest.mark.asyncio, + pytest.mark.asyncio(scope="session"), pytest.mark.skipif(shutil.which('makepkg') is None, reason='requires makepkg command'), pytest.mark.skipif(shutil.which('repo-add') is None, reason='requires repo-add command') ] diff --git a/tests/test_alpmfiles.py b/tests/test_alpmfiles.py index de7c9c9..f27f9e7 100644 --- a/tests/test_alpmfiles.py +++ b/tests/test_alpmfiles.py @@ -9,7 +9,7 @@ import tempfile import pytest pytestmark = [ - pytest.mark.asyncio, + pytest.mark.asyncio(scope="session"), pytest.mark.skipif(shutil.which('pacman') is None, reason='requires pacman command'), pytest.mark.skipif(shutil.which('fakeroot') is None, reason='requires fakeroot command'), ] diff --git a/tests/test_android_sdk.py b/tests/test_android_sdk.py index a50716b..269ef54 100644 --- a/tests/test_android_sdk.py +++ b/tests/test_android_sdk.py @@ -3,7 +3,7 @@ # Copyright (c) 2017 Chih-Hsuan Yen import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_android_addon(get_version): assert await get_version("android-google-play-apk-expansion", { diff --git a/tests/test_anitya.py b/tests/test_anitya.py index 510f080..ae0ac3c 100644 --- a/tests/test_anitya.py +++ b/tests/test_anitya.py @@ -5,7 +5,7 @@ import re import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_anitya(get_version): version = await get_version("shutter", { diff --git a/tests/test_apt.py b/tests/test_apt.py index 5ac92c4..6034986 100644 --- a/tests/test_apt.py +++ b/tests/test_apt.py @@ -4,7 +4,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky(max_runs=10) async def test_apt(get_version): diff --git a/tests/test_archpkg.py b/tests/test_archpkg.py index 0985173..084f6dd 100644 --- a/tests/test_archpkg.py +++ b/tests/test_archpkg.py @@ -3,7 +3,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky async def test_archpkg(get_version): diff --git a/tests/test_aur.py b/tests/test_aur.py index 5a171da..bf5e30c 100644 --- a/tests/test_aur.py +++ b/tests/test_aur.py @@ -5,7 +5,7 @@ import os from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net, pytest.mark.skipif(os.environ.get('TRAVIS') == 'true', reason="fail too often")] diff --git a/tests/test_bitbucket.py b/tests/test_bitbucket.py index 8efb01d..084135f 100644 --- a/tests/test_bitbucket.py +++ b/tests/test_bitbucket.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_bitbucket(get_version): assert await get_version("example", { diff --git a/tests/test_cache.py b/tests/test_cache.py index d64788b..4076bcc 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -2,7 +2,7 @@ # Copyright (c) 2020 lilydjwg , et al. import pytest -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") async def test_cache(run_str_multi): conf = r''' diff --git a/tests/test_cmd.py b/tests/test_cmd.py index 5f8a464..499ba47 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -3,7 +3,7 @@ import time import pytest -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") async def test_cmd(get_version): assert await get_version("example", { diff --git a/tests/test_combiner.py b/tests/test_combiner.py index 21fcbf0..85ee699 100644 --- a/tests/test_combiner.py +++ b/tests/test_combiner.py @@ -2,7 +2,7 @@ # Copyright (c) 2021 lilydjwg , et al. import pytest -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") async def test_combiner(run_str_multi): conf = r''' diff --git a/tests/test_container.py b/tests/test_container.py index 4429315..f0e5277 100644 --- a/tests/test_container.py +++ b/tests/test_container.py @@ -3,7 +3,7 @@ import pytest import datetime -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_container(get_version): assert await get_version("hello-world", { diff --git a/tests/test_cpan.py b/tests/test_cpan.py index ed1e488..d1e26c0 100644 --- a/tests/test_cpan.py +++ b/tests/test_cpan.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_cpan(get_version): assert await get_version("POE-Component-Server-HTTPServer", { diff --git a/tests/test_cran.py b/tests/test_cran.py index e3e4f71..88ff67f 100644 --- a/tests/test_cran.py +++ b/tests/test_cran.py @@ -2,7 +2,7 @@ # Copyright (c) 2022 Pekka Ristola , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_cran(get_version): assert await get_version("xml2", { diff --git a/tests/test_cratesio.py b/tests/test_cratesio.py index c7678d0..bb4bf25 100644 --- a/tests/test_cratesio.py +++ b/tests/test_cratesio.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_cratesio(get_version): assert await get_version("example", { diff --git a/tests/test_debianpkg.py b/tests/test_debianpkg.py index 4c831cc..3982cae 100644 --- a/tests/test_debianpkg.py +++ b/tests/test_debianpkg.py @@ -4,7 +4,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky(max_runs=10) async def test_debianpkg(get_version): diff --git a/tests/test_gems.py b/tests/test_gems.py index f51f179..7d91499 100644 --- a/tests/test_gems.py +++ b/tests/test_gems.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_gems(get_version): assert await get_version("example", { diff --git a/tests/test_git.py b/tests/test_git.py index c570a02..fad6648 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -2,7 +2,7 @@ # Copyright (c) 2020 Felix Yan , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_git(get_version): assert await get_version("example", { diff --git a/tests/test_gitea.py b/tests/test_gitea.py index c58fe09..92416d6 100644 --- a/tests/test_gitea.py +++ b/tests/test_gitea.py @@ -3,7 +3,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky(max_runs=10) diff --git a/tests/test_github.py b/tests/test_github.py index 23cef9a..ad512d5 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -5,7 +5,7 @@ import re import pytest -pytestmark = [pytest.mark.asyncio, +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net, pytest.mark.usefixtures('keyfile')] diff --git a/tests/test_gitlab.py b/tests/test_gitlab.py index 6afce5a..d5da179 100644 --- a/tests/test_gitlab.py +++ b/tests/test_gitlab.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_gitlab(get_version): ver = await get_version("example", { diff --git a/tests/test_hackage.py b/tests/test_hackage.py index 36a3219..02c59fe 100644 --- a/tests/test_hackage.py +++ b/tests/test_hackage.py @@ -3,7 +3,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky(max_runs=10) async def test_hackage(get_version): diff --git a/tests/test_htmlparser.py b/tests/test_htmlparser.py index aed9f73..69ec117 100644 --- a/tests/test_htmlparser.py +++ b/tests/test_htmlparser.py @@ -10,7 +10,7 @@ except ImportError: lxml_available = False pytestmark = [ - pytest.mark.asyncio, + pytest.mark.asyncio(scope="session"), pytest.mark.needs_net, pytest.mark.skipif(not lxml_available, reason="needs lxml"), ] diff --git a/tests/test_httpheader.py b/tests/test_httpheader.py index 68ddb51..a862513 100644 --- a/tests/test_httpheader.py +++ b/tests/test_httpheader.py @@ -5,7 +5,7 @@ import pytest import pytest_httpbin assert pytest_httpbin # for pyflakes -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_redirection(get_version): assert await get_version("unifiedremote", { diff --git a/tests/test_manual.py b/tests/test_manual.py index 1818832..0ceeadb 100644 --- a/tests/test_manual.py +++ b/tests/test_manual.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") async def test_manual(get_version): assert await get_version("example", { diff --git a/tests/test_npm.py b/tests/test_npm.py index 2e11385..b1aea02 100644 --- a/tests/test_npm.py +++ b/tests/test_npm.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_npm(get_version): assert await get_version("example", { diff --git a/tests/test_openvsx.py b/tests/test_openvsx.py index 8ce80db..ae7e08b 100644 --- a/tests/test_openvsx.py +++ b/tests/test_openvsx.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2021 Th3Whit3Wolf , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_openvsx(get_version): assert await get_version("usernamehw.indent-one-space", { diff --git a/tests/test_packagist.py b/tests/test_packagist.py index 71f005e..c48fae6 100644 --- a/tests/test_packagist.py +++ b/tests/test_packagist.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_packagist(get_version): assert await get_version("butterfly/example-web-application", { diff --git a/tests/test_pacman.py b/tests/test_pacman.py index 377b177..58c397c 100644 --- a/tests/test_pacman.py +++ b/tests/test_pacman.py @@ -4,7 +4,7 @@ import pathlib import shutil import pytest -pytestmark = [pytest.mark.asyncio, +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.skipif(shutil.which("pacman") is None, reason="requires pacman command"), pytest.mark.skipif(not pathlib.Path("/var/lib/pacman/sync/core.db").exists(), diff --git a/tests/test_pagure.py b/tests/test_pagure.py index daeb966..9282aa6 100644 --- a/tests/test_pagure.py +++ b/tests/test_pagure.py @@ -2,7 +2,7 @@ # Copyright (c) 2020 Felix Yan , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_pagure(get_version): ver = await get_version("example", { diff --git a/tests/test_pypi.py b/tests/test_pypi.py index 1d7c404..7faa447 100644 --- a/tests/test_pypi.py +++ b/tests/test_pypi.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_pypi(get_version): assert await get_version("example", { diff --git a/tests/test_regex.py b/tests/test_regex.py index 6019631..0e1e7d5 100644 --- a/tests/test_regex.py +++ b/tests/test_regex.py @@ -7,7 +7,7 @@ import pytest import pytest_httpbin assert pytest_httpbin # for pyflakes -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") def base64_encode(s): return base64.b64encode(s.encode('utf-8')).decode('ascii') diff --git a/tests/test_repology.py b/tests/test_repology.py index 5650736..6cc7a69 100644 --- a/tests/test_repology.py +++ b/tests/test_repology.py @@ -3,7 +3,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky(max_runs=10) diff --git a/tests/test_sparkle.py b/tests/test_sparkle.py index 88446a8..c68a7e1 100644 --- a/tests/test_sparkle.py +++ b/tests/test_sparkle.py @@ -3,7 +3,7 @@ # Copyright (c) 2020 Sunlei import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_sparkle(get_version): assert await get_version('example', { diff --git a/tests/test_substitute.py b/tests/test_substitute.py index 57a5352..cf5c212 100644 --- a/tests/test_substitute.py +++ b/tests/test_substitute.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2020 lilydjwg , et al. import pytest -pytestmark = pytest.mark.asyncio +pytestmark = pytest.mark.asyncio(scope="session") async def test_substitute_prefix(get_version): assert await get_version("example", { diff --git a/tests/test_ubuntupkg.py b/tests/test_ubuntupkg.py index 6f125c3..b9d1b7c 100644 --- a/tests/test_ubuntupkg.py +++ b/tests/test_ubuntupkg.py @@ -4,7 +4,7 @@ from flaky import flaky import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] @flaky async def test_ubuntupkg(get_version): diff --git a/tests/test_vsmarketplace.py b/tests/test_vsmarketplace.py index 1a14081..f03b450 100644 --- a/tests/test_vsmarketplace.py +++ b/tests/test_vsmarketplace.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2021 Th3Whit3Wolf , et al. import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] async def test_vsmarketplace(get_version): assert await get_version("usernamehw.indent-one-space", {