From 471b66ff4c4d76716298fa425ad9feb31ee6de7b Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 9 Mar 2024 20:21:55 +0800 Subject: [PATCH] tests: use pytest-rerunfailures instead of flaky flaky is no longer compatible with pytest 8.0 and seems unmaintained. https://github.com/pytest-dev/pytest/issues/12066 --- .github/workflows/mypy.yaml | 2 +- .github/workflows/tests.yaml | 2 +- tests/test_apt.py | 9 ++++----- tests/test_archpkg.py | 9 ++++----- tests/test_aur.py | 7 +++---- tests/test_debianpkg.py | 7 +++---- tests/test_gitea.py | 5 ++--- tests/test_hackage.py | 3 +-- tests/test_repology.py | 5 ++--- tests/test_ubuntupkg.py | 9 ++++----- 10 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index 0ff070d..7ab80bb 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -18,7 +18,7 @@ jobs: ${{ runner.os }}-${{ env.cache-name }}- ${{ runner.os }}-cache-pip- - name: Install deps - run: pip3 install -U tornado pytest pytest-asyncio pytest-httpbin flaky structlog tomli platformdirs aiohttp httpx mypy awesomeversion + run: pip3 install -U tornado pytest pytest-asyncio pytest-httpbin pytest-rerunfailures structlog tomli platformdirs aiohttp httpx mypy awesomeversion - name: Run mypy for --install-types run: PATH=$HOME/.local/bin:$PATH mypy --namespace-packages --explicit-package-bases nvchecker nvchecker_source tests continue-on-error: true diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 91e97f5..7b09b7a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 flaky structlog tomli platformdirs lxml 'werkzeug<2.1' awesomeversion + run: pip install -U ${{ matrix.deps }} pytest 'pytest-asyncio>=0.23' pytest-httpbin pytest-rerunfailures structlog tomli platformdirs lxml 'werkzeug<2.1' awesomeversion - name: Decrypt keys env: KEY: ${{ secrets.KEY }} diff --git a/tests/test_apt.py b/tests/test_apt.py index 6034986..ccf4b78 100644 --- a/tests/test_apt.py +++ b/tests/test_apt.py @@ -2,11 +2,10 @@ # Copyright (c) 2020-2021 lilydjwg , et al. # Copyright (c) 2017 Felix Yan , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_apt(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "apt", @@ -14,7 +13,7 @@ async def test_apt(get_version): "suite": "sid", }) == "0.1.7-1" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_apt_srcpkg(get_version): ver = await get_version("test", { "source": "apt", @@ -24,7 +23,7 @@ async def test_apt_srcpkg(get_version): }) assert ver.startswith("0.0~git20150829.56e4718-") -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_apt_strip_release(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "apt", @@ -34,7 +33,7 @@ async def test_apt_strip_release(get_version): }) == "0.1.7" @pytest.mark.skip -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_apt_deepin(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "apt", diff --git a/tests/test_archpkg.py b/tests/test_archpkg.py index 084f6dd..410686c 100644 --- a/tests/test_archpkg.py +++ b/tests/test_archpkg.py @@ -1,31 +1,30 @@ # MIT licensed # Copyright (c) 2013-2020 lilydjwg , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky +@pytest.mark.flaky async def test_archpkg(get_version): assert await get_version("base", { "source": "archpkg", }) == "3-2" -@flaky +@pytest.mark.flaky async def test_archpkg_strip_release(get_version): assert await get_version("base", { "source": "archpkg", "strip_release": True, }) == "3" -@flaky +@pytest.mark.flaky async def test_archpkg_provided(get_version): assert await get_version("dbus", { "source": "archpkg", "provided": "libdbus-1.so", }) == "3-64" -@flaky +@pytest.mark.flaky async def test_archpkg_provided_strip(get_version): assert await get_version("jsoncpp", { "source": "archpkg", diff --git a/tests/test_aur.py b/tests/test_aur.py index bf5e30c..57a9f47 100644 --- a/tests/test_aur.py +++ b/tests/test_aur.py @@ -3,27 +3,26 @@ import os -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net, pytest.mark.skipif(os.environ.get('TRAVIS') == 'true', reason="fail too often")] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_aur(get_version): assert await get_version("ssed", { "source": "aur", }) == "3.62-2" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_aur_strip_release(get_version): assert await get_version("ssed", { "source": "aur", "strip_release": 1, }) == "3.62" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_aur_use_last_modified(get_version): assert await get_version("ssed", { "source": "aur", diff --git a/tests/test_debianpkg.py b/tests/test_debianpkg.py index 3982cae..f1e2462 100644 --- a/tests/test_debianpkg.py +++ b/tests/test_debianpkg.py @@ -2,24 +2,23 @@ # Copyright (c) 2020 lilydjwg , et al. # Copyright (c) 2017 Felix Yan , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_debianpkg(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "debianpkg", }) == "0.1.7-1" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_debianpkg_strip_release(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "debianpkg", "strip_release": 1, }) == "0.1.7" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_debianpkg_suite(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "debianpkg", diff --git a/tests/test_gitea.py b/tests/test_gitea.py index 92416d6..01c49ff 100644 --- a/tests/test_gitea.py +++ b/tests/test_gitea.py @@ -1,12 +1,11 @@ # MIT licensed # Copyright (c) 2013-2020 lilydjwg , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_gitea(get_version): ver = await get_version("example", { "source": "gitea", @@ -14,7 +13,7 @@ async def test_gitea(get_version): assert len(ver) == 8 assert ver.isdigit() -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_gitea_max_tag_with_include(get_version): assert await get_version("example", { "source": "gitea", diff --git a/tests/test_hackage.py b/tests/test_hackage.py index 02c59fe..2a7d0e0 100644 --- a/tests/test_hackage.py +++ b/tests/test_hackage.py @@ -1,11 +1,10 @@ # MIT licensed # Copyright (c) 2013-2020 lilydjwg , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_hackage(get_version): assert await get_version("sessions", { "source": "hackage", diff --git a/tests/test_repology.py b/tests/test_repology.py index 6cc7a69..c2f15cf 100644 --- a/tests/test_repology.py +++ b/tests/test_repology.py @@ -1,19 +1,18 @@ # MIT licensed # Copyright (c) 2019-2020 lilydjwg , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_repology(get_version): assert await get_version("ssed", { "source": "repology", "repo": "aur", }) == "3.62" -@flaky(max_runs=10) +@pytest.mark.flaky(reruns=10) async def test_repology_subrepo(get_version): assert await get_version("asciiquarium", { "source": "repology", diff --git a/tests/test_ubuntupkg.py b/tests/test_ubuntupkg.py index b9d1b7c..4f393db 100644 --- a/tests/test_ubuntupkg.py +++ b/tests/test_ubuntupkg.py @@ -2,31 +2,30 @@ # Copyright (c) 2020 lilydjwg , et al. # Copyright (c) 2017 Felix Yan , et al. -from flaky import flaky import pytest pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net] -@flaky +@pytest.mark.flaky async def test_ubuntupkg(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "ubuntupkg", }) == "0.1.7-1" -@flaky +@pytest.mark.flaky async def test_ubuntupkg_strip_release(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "ubuntupkg", "strip_release": True, }) == "0.1.7" -@flaky +@pytest.mark.flaky async def test_ubuntupkg_suite(get_version): assert await get_version("sigrok-firmware-fx2lafw", { "source": "ubuntupkg", "suite": "xenial", }) == "0.1.2-1" -@flaky +@pytest.mark.flaky async def test_ubuntupkg_suite_with_paging(get_version): assert await get_version("ffmpeg", { "source": "ubuntupkg",