tests: fix for pytest-asyncio 0.23

This commit is contained in:
Chih-Hsuan Yen 2023-12-09 19:17:31 +08:00 committed by lilydjwg
parent 918457afed
commit 4ca61ba11a
38 changed files with 40 additions and 49 deletions

View file

@ -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):

View file

@ -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')
]

View file

@ -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'),
]

View file

@ -3,7 +3,7 @@
# Copyright (c) 2017 Chih-Hsuan Yen <yan12125 at gmail dot com>
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", {

View file

@ -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", {

View file

@ -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):

View file

@ -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):

View file

@ -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")]

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio
pytestmark = pytest.mark.asyncio(scope="session")
async def test_cache(run_str_multi):
conf = r'''

View file

@ -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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2021 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio
pytestmark = pytest.mark.asyncio(scope="session")
async def test_combiner(run_str_multi):
conf = r'''

View file

@ -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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2022 Pekka Ristola <pekkarr [at] protonmail [dot] com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -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):

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, 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", {

View file

@ -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)

View file

@ -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')]

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -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):

View file

@ -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"),
]

View file

@ -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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2021 Th3Whit3Wolf <the.white.wolf.is.1337@gmail.com>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -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(),

View file

@ -2,7 +2,7 @@
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, 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", {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -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')

View file

@ -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)

View file

@ -3,7 +3,7 @@
# Copyright (c) 2020 Sunlei <guizaicn@gmail.com>
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', {

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, 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", {

View file

@ -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):

View file

@ -2,7 +2,7 @@
# Copyright (c) 2013-2021 Th3Whit3Wolf <the.white.wolf.is.1337@gmail.com>, 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", {