From 510b0e5745857b537c055c4f060fbcb7cc540511 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 4 Mar 2024 08:54:20 -0500 Subject: [PATCH] Stop using flaky lib, use pytest-rerunfailures instead (#1296) * Stop using flaky lib, use pytest-rerunfailures instead flaky is not compatible with the latest pytest release and appears unmaintained, while pytest-rerunfailures is maintained by the pytest team * ruff --- setup.py | 2 +- tests/test_crypto.py | 6 +++--- tests/test_ssl.py | 3 +-- tests/util.py | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 2f0231688..db715636d 100644 --- a/setup.py +++ b/setup.py @@ -96,7 +96,7 @@ def find_meta(meta): "cryptography>=41.0.5,<43", ], extras_require={ - "test": ["flaky", "pretend", "pytest>=3.0.1"], + "test": ["pytest-rerunfailures", "pretend", "pytest>=3.0.1"], "docs": [ "sphinx!=5.2.0,!=5.2.0.post0,!=7.2.5", "sphinx_rtd_theme", diff --git a/tests/test_crypto.py b/tests/test_crypto.py index b9bb0de63..76d6be631 100644 --- a/tests/test_crypto.py +++ b/tests/test_crypto.py @@ -4,13 +4,13 @@ """ Unit tests for :py:mod:`OpenSSL.crypto`. """ + import base64 import sys import warnings from datetime import datetime, timedelta, timezone from subprocess import PIPE, Popen -import flaky import pytest from cryptography import x509 from cryptography.hazmat.primitives import hashes, serialization @@ -1864,7 +1864,7 @@ def test_gmtime_adj_notBefore_wrong_args(self): with pytest.raises(TypeError): cert.gmtime_adj_notBefore(None) - @flaky.flaky + @pytest.mark.flaky(reruns=2) def test_gmtime_adj_notBefore(self): """ `X509.gmtime_adj_notBefore` changes the not-before timestamp to be the @@ -1890,7 +1890,7 @@ def test_gmtime_adj_notAfter_wrong_args(self): with pytest.raises(TypeError): cert.gmtime_adj_notAfter(None) - @flaky.flaky + @pytest.mark.flaky(reruns=2) def test_gmtime_adj_notAfter(self): """ `X509.gmtime_adj_notAfter` changes the not-after timestamp diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 5ea068a48..333ca26e9 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -34,7 +34,6 @@ from typing import Union from weakref import ref -import flaky import pytest from cryptography import x509 from cryptography.hazmat.primitives import hashes, serialization @@ -510,7 +509,7 @@ def test_set_cipher_list_wrong_type(self, context): with pytest.raises(TypeError): context.set_cipher_list(object()) - @flaky.flaky + @pytest.mark.flaky(reruns=2) def test_set_cipher_list_no_cipher_match(self, context): """ `Context.set_cipher_list` raises `OpenSSL.SSL.Error` with a diff --git a/tests/util.py b/tests/util.py index b4649e339..83accb660 100644 --- a/tests/util.py +++ b/tests/util.py @@ -6,7 +6,6 @@ U{Twisted}. """ - # This is the UTF-8 encoding of the SNOWMAN unicode code point. NON_ASCII = b"\xe2\x98\x83".decode("utf-8")