Skip to content

Commit

Permalink
tests: use asyncio_default_fixture_loop_scope = "session"
Browse files Browse the repository at this point in the history
  • Loading branch information
lilydjwg committed Nov 3, 2024
1 parent 4eb70a0 commit 89b4cd9
Show file tree
Hide file tree
Showing 43 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
2 changes: 1 addition & 1 deletion tests/test_alpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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')
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_alpmfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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'),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_android_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_anitya.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <[email protected]>, 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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_archpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aur.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2020 lilydjwg <[email protected]>, et al.

import pytest
pytestmark = pytest.mark.asyncio(scope="session")
pytestmark = pytest.mark.asyncio

async def test_cache(run_str_multi):
conf = r'''
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2021 lilydjwg <[email protected]>, et al.

import pytest
pytestmark = pytest.mark.asyncio(scope="session")
pytestmark = pytest.mark.asyncio

async def test_combiner(run_str_multi):
conf = r'''
Expand Down
2 changes: 1 addition & 1 deletion tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cratesio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_debianpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <[email protected]>, 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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gems.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2020 Felix Yan <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gitea.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, et al.

import pytest
pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net]

@pytest.mark.flaky(reruns=10)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net,
pytest.mark.usefixtures('keyfile')]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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")
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_htmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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"),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_httpheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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"),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_launchpad.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MIT Licensed
# Copyright (c) 2024 Bert Peters <[email protected]>, 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(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.needs_net,
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_openvsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2021 Th3Whit3Wolf <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_packagist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2020 Felix Yan <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
httpbin_available = False

pytestmark = [
pytest.mark.asyncio(scope="session"),
pytest.mark.asyncio,
pytest.mark.skipif(not httpbin_available, reason="needs pytest_httpbin"),
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_repology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2019-2020 lilydjwg <[email protected]>, et al.

import pytest
pytestmark = [pytest.mark.asyncio(scope="session"),
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net]

@pytest.mark.flaky(reruns=10)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sparkle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2020 Sunlei <[email protected]>

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', {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2020 lilydjwg <[email protected]>, 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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ubuntupkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2017 Felix Yan <[email protected]>, 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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vsmarketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2013-2021 Th3Whit3Wolf <[email protected]>, 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", {
Expand Down

0 comments on commit 89b4cd9

Please sign in to comment.