diff --git a/Lib/test/support/hypothesis_helper.py b/Lib/test/support/hypothesis_helper.py index 6249ba43f06716a..769d031cfcce15b 100644 --- a/Lib/test/support/hypothesis_helper.py +++ b/Lib/test/support/hypothesis_helper.py @@ -1,5 +1,7 @@ import os +from test.support import mark + try: import hypothesis except ImportError: @@ -55,3 +57,5 @@ ), ) hypothesis.settings.load_profile("cpython-local-dev") + +mark_hypothesis = mark("hypothesis") diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py index 868abcfee24e101..e7da3f76ea92548 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -16,7 +16,7 @@ class LazyImportTest(unittest.TestCase): def test_lazy_import(self): ensure_lazy_imports("base64", {"re", "getopt"}) -from test.support.hypothesis_helper import hypothesis +from test.support.hypothesis_helper import hypothesis, mark_hypothesis class LegacyBase64TestCase(unittest.TestCase): @@ -74,6 +74,7 @@ def test_decodebytes(self): @hypothesis.given(payload=hypothesis.strategies.binary()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz') + @mark_hypothesis def test_bytes_encode_decode_round_trip(self, payload): encoded = base64.encodebytes(payload) decoded = base64.decodebytes(encoded) @@ -109,6 +110,7 @@ def test_decode(self): @hypothesis.given(payload=hypothesis.strategies.binary()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz') + @mark_hypothesis def test_legacy_encode_decode_round_trip(self, payload): from io import BytesIO payload_file_r = BytesIO(payload) @@ -503,6 +505,7 @@ def _altchars_strategy(): validate=hypothesis.strategies.booleans()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", False) + @mark_hypothesis def test_b64_encode_decode_round_trip(self, payload, altchars, validate): encoded = base64.b64encode(payload, altchars=altchars) decoded = base64.b64decode(encoded, altchars=altchars, @@ -511,6 +514,7 @@ def test_b64_encode_decode_round_trip(self, payload, altchars, validate): @hypothesis.given(payload=hypothesis.strategies.binary()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz') + @mark_hypothesis def test_standard_b64_encode_decode_round_trip(self, payload): encoded = base64.standard_b64encode(payload) decoded = base64.standard_b64decode(encoded) @@ -518,6 +522,7 @@ def test_standard_b64_encode_decode_round_trip(self, payload): @hypothesis.given(payload=hypothesis.strategies.binary()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz') + @mark_hypothesis def test_urlsafe_b64_encode_decode_round_trip(self, payload): encoded = base64.urlsafe_b64encode(payload) decoded = base64.urlsafe_b64decode(encoded) @@ -701,6 +706,7 @@ def test_b32decode_error(self): | hypothesis.strategies.binary(min_size=1, max_size=1))) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True, None) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False, None) + @mark_hypothesis def test_b32_encode_decode_round_trip(self, payload, casefold, map01): encoded = base64.b32encode(payload) decoded = base64.b32decode(encoded, casefold=casefold, map01=map01) @@ -837,6 +843,7 @@ def test_b32hexdecode_error(self): casefold=hypothesis.strategies.booleans()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False) + @mark_hypothesis def test_b32_hexencode_decode_round_trip(self, payload, casefold): encoded = base64.b32hexencode(payload) decoded = base64.b32hexdecode(encoded, casefold=casefold) @@ -899,6 +906,7 @@ def test_b16decode_ignorechars(self): casefold=hypothesis.strategies.booleans()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False) + @mark_hypothesis def test_b16_encode_decode_round_trip(self, payload, casefold): endoded = base64.b16encode(payload) decoded = base64.b16decode(endoded, casefold=casefold) @@ -1321,6 +1329,7 @@ def add_padding(self, payload): @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False, 20, True, True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True, 0, False, True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True, 20, True, False) + @mark_hypothesis def test_a85_encode_decode_round_trip( self, payload, foldspaces, wrapcol, pad, adobe ): @@ -1349,6 +1358,7 @@ def test_a85_encode_decode_round_trip( pad=hypothesis.strategies.booleans()) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True) @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False) + @mark_hypothesis def test_b85_encode_decode_round_trip(self, payload, pad): encoded = base64.b85encode(payload, pad=pad) if pad: diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 77ea77ed37bdc59..94b1abd4079efd1 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -6,7 +6,7 @@ import re import sys from test.support import bigmemtest, _1G, _4G, check_impl_detail -from test.support.hypothesis_helper import hypothesis +from test.support.hypothesis_helper import hypothesis, mark_hypothesis # Note: "*_hex" functions are aliases for "(un)hexlify" @@ -420,6 +420,7 @@ def test_base64_canonical(self): @hypothesis.example(b'\x00') @hypothesis.example(b'\xff\xff') @hypothesis.example(b'abc') + @mark_hypothesis def test_base64_canonical_roundtrip(self, payload): # The encoder must always produce canonical output. encoded = binascii.b2a_base64(payload, newline=False) @@ -866,6 +867,7 @@ def test_base85_canonical(self): @hypothesis.example(b'\x00') @hypothesis.example(b'\xff\xff') @hypothesis.example(b'abc') + @mark_hypothesis def test_base85_canonical_roundtrip(self, payload): encoded = binascii.b2a_base85(payload) decoded = binascii.a2b_base85(encoded, canonical=True) @@ -875,6 +877,7 @@ def test_base85_canonical_roundtrip(self, payload): @hypothesis.example(b'\x00') @hypothesis.example(b'\xff') @hypothesis.example(b'ab\x00') + @mark_hypothesis def test_base85_canonical_unique(self, payload): # For a partial group, sweeping all 85 last-digit values should # yield exactly one encoding that both decodes to the original @@ -953,6 +956,7 @@ def test_ascii85_canonical(self): @hypothesis.example(b'\x00\x00\x00\x00') # triggers z abbreviation @hypothesis.example(b'\xff\xff') @hypothesis.example(b'abc') + @mark_hypothesis def test_ascii85_canonical_roundtrip(self, payload): encoded = binascii.b2a_ascii85(payload) decoded = binascii.a2b_ascii85(encoded, canonical=True) @@ -962,6 +966,7 @@ def test_ascii85_canonical_roundtrip(self, payload): @hypothesis.example(b'\x00') @hypothesis.example(b'\xff') @hypothesis.example(b'ab\x00') + @mark_hypothesis def test_ascii85_canonical_unique(self, payload): hypothesis.assume(len(payload) % 4 != 0) canonical_enc = binascii.b2a_ascii85(payload) @@ -1189,6 +1194,7 @@ def test_base32_canonical(self): @hypothesis.example(b'\x00') @hypothesis.example(b'\xff\xff') @hypothesis.example(b'abc') + @mark_hypothesis def test_base32_canonical_roundtrip(self, payload): encoded = binascii.b2a_base32(payload) decoded = binascii.a2b_base32(encoded, canonical=True) @@ -1331,6 +1337,7 @@ def test_uu(self): binary=hypothesis.strategies.binary(max_size=45), backtick=hypothesis.strategies.booleans(), ) + @mark_hypothesis def test_b2a_roundtrip(self, binary, backtick): converted = binascii.b2a_uu(self.type2test(binary), backtick=backtick) restored = binascii.a2b_uu(self.type2test(converted)) @@ -1374,6 +1381,7 @@ def test_hex(self): self.assertEqual(binascii.unhexlify(self.type2test(t)), u) @hypothesis.given(binary=hypothesis.strategies.binary()) + @mark_hypothesis def test_hex_roundtrip(self, binary): converted = binascii.hexlify(self.type2test(binary)) restored = binascii.unhexlify(self.type2test(converted)) @@ -1527,6 +1535,7 @@ def test_qp(self): istext=hypothesis.strategies.booleans(), header=hypothesis.strategies.booleans(), ) + @mark_hypothesis def test_b2a_qp_a2b_qp_round_trip(self, binary, quotetabs, istext, header): converted = binascii.b2a_qp( self.type2test(binary), @@ -1624,6 +1633,7 @@ def test_b2a_base64_wrapcol(self): binary=hypothesis.strategies.binary(), newline=hypothesis.strategies.booleans(), ) + @mark_hypothesis def test_base64_roundtrip(self, binary, newline): converted = binascii.b2a_base64(self.type2test(binary), newline=newline) restored = binascii.a2b_base64(self.type2test(converted)) diff --git a/Lib/test/test_math_property.py b/Lib/test/test_math_property.py index 7d51aa17b4cc270..a4b901fb4d4f359 100644 --- a/Lib/test/test_math_property.py +++ b/Lib/test/test_math_property.py @@ -1,9 +1,11 @@ import functools import unittest from math import isnan, nextafter -from test.support import requires_IEEE_754 +from test.support import requires_IEEE_754, mark_module from test.support.hypothesis_helper import hypothesis +mark_module('hypothesis') + floats = hypothesis.strategies.floats integers = hypothesis.strategies.integers diff --git a/Lib/test/test_tools/test_makeunicodedata.py b/Lib/test/test_tools/test_makeunicodedata.py index f31375117e2e926..3f34584239d70c0 100644 --- a/Lib/test/test_tools/test_makeunicodedata.py +++ b/Lib/test/test_tools/test_makeunicodedata.py @@ -1,7 +1,7 @@ import unittest from test.test_tools import skip_if_missing, imports_under_tool from test import support -from test.support.hypothesis_helper import hypothesis +from test.support.hypothesis_helper import hypothesis, mark_hypothesis st = hypothesis.strategies given = hypothesis.given @@ -115,6 +115,7 @@ def test_forbid_empty_dawg(self): ("ab", "1"), ] ) + @mark_hypothesis def test_dawg(self, data): # suppress debug prints with support.captured_stdout() as output: diff --git a/Lib/test/test_zoneinfo/test_zoneinfo_property.py b/Lib/test/test_zoneinfo/test_zoneinfo_property.py index c00815e2fd4c364..78bb8098bb56ba1 100644 --- a/Lib/test/test_zoneinfo/test_zoneinfo_property.py +++ b/Lib/test/test_zoneinfo/test_zoneinfo_property.py @@ -5,10 +5,13 @@ import unittest import zoneinfo +from test.support import mark_module from test.support.hypothesis_helper import hypothesis import test.test_zoneinfo._support as test_support +mark_module('hypothesis') + ZoneInfoTestBase = test_support.ZoneInfoTestBase py_zoneinfo, c_zoneinfo = test_support.get_modules()