tests: use asyncio_default_fixture_loop_scope = "session"

See also https://github.com/pytest-dev/pytest-asyncio/issues/924.
This commit is contained in:
lilydjwg 2024-11-03 18:29:19 +08:00
parent 4eb70a0fbe
commit 89b4cd90ba
43 changed files with 43 additions and 42 deletions

View File

@ -47,7 +47,7 @@ jobs:
sudo ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt
# werkzeug is pinned for httpbin compatibility https://github.com/postmanlabs/httpbin/issues/673
- name: Install Python deps
run: pip install -U ${{ matrix.deps }} pytest 'pytest-asyncio>=0.23' pytest-httpbin pytest-rerunfailures structlog tomli platformdirs lxml jq 'werkzeug<2.1' awesomeversion
run: pip install -U ${{ matrix.deps }} pytest 'pytest-asyncio>=0.24' pytest-httpbin pytest-rerunfailures structlog tomli platformdirs lxml jq 'werkzeug<2.1' awesomeversion
- name: Decrypt keys
env:
KEY: ${{ secrets.KEY }}

View File

@ -5,6 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
# addopts = -n auto
asyncio_mode = "strict"
asyncio_default_fixture_loop_scope = "session"
# build and upload
# rm -rf dist && python -m build --no-isolation && twine check dist/* && twine upload dist/*

View File

@ -9,7 +9,7 @@ import tempfile
import pytest
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
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(scope="session"),
pytest.mark.asyncio,
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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_anitya(get_version):
version = await get_version("shutter", {

View File

@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@pytest.mark.flaky(reruns=10)
async def test_apt(get_version):

View File

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@pytest.mark.flaky
async def test_archpkg(get_version):

View File

@ -4,7 +4,7 @@
import os
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session")
pytestmark = pytest.mark.asyncio
async def test_cache(run_str_multi):
conf = r'''

View File

@ -3,7 +3,7 @@
import time
import pytest
pytestmark = pytest.mark.asyncio(scope="session")
pytestmark = pytest.mark.asyncio
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(scope="session")
pytestmark = pytest.mark.asyncio
async def test_combiner(run_str_multi):
conf = r'''

View File

@ -3,7 +3,7 @@
import pytest
import datetime
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_cratesio(get_version):
assert await get_version("example", {

View File

@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@pytest.mark.flaky(reruns=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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_git(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(scope="session"),
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net]
@pytest.mark.flaky(reruns=10)

View File

@ -5,7 +5,7 @@ import re
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_gitlab(get_version):
ver = await get_version("example", {

View File

@ -12,7 +12,7 @@ except ImportError:
lxml_available = False
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.needs_net,
pytest.mark.skipif(not lxml_available, reason="needs lxml")
]

View File

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@pytest.mark.flaky(reruns=10)
async def test_hackage(get_version):

View File

@ -10,7 +10,7 @@ except ImportError:
lxml_available = False
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.needs_net,
pytest.mark.skipif(not lxml_available, reason="needs lxml"),
]

View File

@ -10,7 +10,7 @@ try:
except ImportError:
httpbin_available = False
pytestmark = pytest.mark.asyncio(scope="session")
pytestmark = pytest.mark.asyncio
@pytest.mark.needs_net
async def test_redirection(get_version):

View File

@ -10,7 +10,7 @@ except ImportError:
jq_available = False
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.needs_net,
pytest.mark.skipif(not jq_available, reason="needs jq"),
]

View File

@ -1,7 +1,7 @@
# MIT Licensed
# Copyright (c) 2024 Bert Peters <bertptrs@archlinux.org>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_launchpad(get_version):
version = await get_version(

View File

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio(scope="session")
pytestmark = pytest.mark.asyncio
async def test_manual(get_version):
assert await get_version("example", {

View File

@ -3,7 +3,7 @@
import pytest
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.needs_net,
]

View File

@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"),
pytestmark = [pytest.mark.asyncio,
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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_pypi(get_version):
assert await get_version("example", {

View File

@ -13,7 +13,7 @@ except ImportError:
httpbin_available = False
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.skipif(not httpbin_available, reason="needs pytest_httpbin"),
]

View File

@ -2,7 +2,7 @@
# Copyright (c) 2019-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net]
@pytest.mark.flaky(reruns=10)

View File

@ -3,7 +3,7 @@
# Copyright (c) 2020 Sunlei <guizaicn@gmail.com>
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, 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(scope="session")
pytestmark = pytest.mark.asyncio
async def test_substitute_prefix(get_version):
assert await get_version("example", {

View File

@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@pytest.mark.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(scope="session"), pytest.mark.needs_net]
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_vsmarketplace(get_version):
assert await get_version("usernamehw.indent-one-space", {