Skip to content

Commit 9550dbc

Browse files
committed
Address review
1 parent 68c0b6b commit 9550dbc

3 files changed

Lines changed: 11 additions & 24 deletions

File tree

‎Lib/test/support/hypothesis_helper.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22

3+
from test.support import mark
4+
35
try:
46
import hypothesis
57
except ImportError:
@@ -56,8 +58,4 @@
5658
)
5759
hypothesis.settings.load_profile("cpython-local-dev")
5860

59-
60-
def mark_hypothesis(func):
61-
from test.support import mark
62-
63-
return mark("hypothesis")(func)
61+
mark_hypothesis = mark("hypothesis")

‎Lib/test/test_math_property.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import functools
22
import unittest
33
from math import isnan, nextafter
4-
from test.support import requires_IEEE_754
5-
from test.support.hypothesis_helper import hypothesis, mark_hypothesis
4+
from test.support import requires_IEEE_754, mark_module
5+
from test.support.hypothesis_helper import hypothesis
6+
7+
mark_module('hypothesis')
68

79
floats = hypothesis.strategies.floats
810
integers = hypothesis.strategies.integers
@@ -22,7 +24,6 @@ class NextafterTests(unittest.TestCase):
2224
x=floats(),
2325
y=floats(),
2426
steps=integers(min_value=0, max_value=2**16))
25-
@mark_hypothesis
2627
def test_count(self, x, y, steps):
2728
assert_equal_float(via_reduce(x, y, steps),
2829
nextafter(x, y, steps=steps))
@@ -33,7 +34,6 @@ def test_count(self, x, y, steps):
3334
y=floats(),
3435
a=integers(min_value=0),
3536
b=integers(min_value=0))
36-
@mark_hypothesis
3737
def test_addition_commutes(self, x, y, a, b):
3838
first = nextafter(x, y, steps=a)
3939
second = nextafter(first, y, steps=b)

‎Lib/test/test_zoneinfo/test_zoneinfo_property.py‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
import unittest
66
import zoneinfo
77

8-
from test.support.hypothesis_helper import hypothesis, mark_hypothesis
8+
from test.support import mark_module
9+
from test.support.hypothesis_helper import hypothesis
910

1011
import test.test_zoneinfo._support as test_support
1112

13+
mark_module('hypothesis')
14+
1215
ZoneInfoTestBase = test_support.ZoneInfoTestBase
1316

1417
py_zoneinfo, c_zoneinfo = test_support.get_modules()
@@ -96,14 +99,12 @@ class ZoneInfoTest(ZoneInfoTestBase):
9699

97100
@hypothesis.given(key=valid_keys())
98101
@add_key_examples
99-
@mark_hypothesis
100102
def test_str(self, key):
101103
zi = self.klass(key)
102104
self.assertEqual(str(zi), key)
103105

104106
@hypothesis.given(key=valid_keys())
105107
@add_key_examples
106-
@mark_hypothesis
107108
def test_key(self, key):
108109
zi = self.klass(key)
109110

@@ -121,7 +122,6 @@ def test_key(self, key):
121122
@hypothesis.example(dt=datetime.time(0))
122123
@hypothesis.example(dt=datetime.time(12, 0))
123124
@hypothesis.example(dt=datetime.time(23, 59, 59, 999999))
124-
@mark_hypothesis
125125
def test_utc(self, dt):
126126
zi = self.klass("UTC")
127127
dt_zi = dt.replace(tzinfo=zi)
@@ -147,7 +147,6 @@ def setUp(self):
147147

148148
@hypothesis.given(key=valid_keys())
149149
@add_key_examples
150-
@mark_hypothesis
151150
def test_pickle_unpickle_cache(self, key):
152151
zi = self.klass(key)
153152
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -158,7 +157,6 @@ def test_pickle_unpickle_cache(self, key):
158157

159158
@hypothesis.given(key=valid_keys())
160159
@add_key_examples
161-
@mark_hypothesis
162160
def test_pickle_unpickle_no_cache(self, key):
163161
zi = self.klass.no_cache(key)
164162
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -170,7 +168,6 @@ def test_pickle_unpickle_no_cache(self, key):
170168

171169
@hypothesis.given(key=valid_keys())
172170
@add_key_examples
173-
@mark_hypothesis
174171
def test_pickle_unpickle_cache_multiple_rounds(self, key):
175172
"""Test that pickle/unpickle is idempotent."""
176173
zi_0 = self.klass(key)
@@ -189,7 +186,6 @@ def test_pickle_unpickle_cache_multiple_rounds(self, key):
189186

190187
@hypothesis.given(key=valid_keys())
191188
@add_key_examples
192-
@mark_hypothesis
193189
def test_pickle_unpickle_no_cache_multiple_rounds(self, key):
194190
"""Test that pickle/unpickle is idempotent."""
195191
zi_cache = self.klass(key)
@@ -222,7 +218,6 @@ class ZoneInfoCacheTest(ZoneInfoTestBase):
222218

223219
@hypothesis.given(key=valid_keys())
224220
@add_key_examples
225-
@mark_hypothesis
226221
def test_cache(self, key):
227222
zi_0 = self.klass(key)
228223
zi_1 = self.klass(key)
@@ -231,7 +226,6 @@ def test_cache(self, key):
231226

232227
@hypothesis.given(key=valid_keys())
233228
@add_key_examples
234-
@mark_hypothesis
235229
def test_no_cache(self, key):
236230
zi_0 = self.klass.no_cache(key)
237231
zi_1 = self.klass.no_cache(key)
@@ -255,7 +249,6 @@ def _is_ambiguous(self, dt):
255249
@hypothesis.example(dt=datetime.datetime(1970, 1, 1), key="America/New_York")
256250
@hypothesis.example(dt=datetime.datetime(2020, 1, 1), key="Europe/Paris")
257251
@hypothesis.example(dt=datetime.datetime(2020, 6, 1), key="Europe/Paris")
258-
@mark_hypothesis
259252
def test_same_str(self, dt, key):
260253
py_dt = dt.replace(tzinfo=py_zoneinfo.ZoneInfo(key))
261254
c_dt = dt.replace(tzinfo=c_zoneinfo.ZoneInfo(key))
@@ -271,7 +264,6 @@ def test_same_str(self, dt, key):
271264
@hypothesis.example(dt=datetime.datetime(2040, 1, 1), key="Europe/Paris")
272265
@hypothesis.example(dt=datetime.datetime.min, key="Asia/Tokyo")
273266
@hypothesis.example(dt=datetime.datetime.max, key="Asia/Tokyo")
274-
@mark_hypothesis
275267
def test_same_offsets_and_names(self, dt, key):
276268
py_dt = dt.replace(tzinfo=py_zoneinfo.ZoneInfo(key))
277269
c_dt = dt.replace(tzinfo=c_zoneinfo.ZoneInfo(key))
@@ -292,7 +284,6 @@ def test_same_offsets_and_names(self, dt, key):
292284
dt=datetime.datetime(2006, 10, 29, 5, 15, tzinfo=UTC),
293285
key="America/New_York",
294286
)
295-
@mark_hypothesis
296287
def test_same_from_utc(self, dt, key):
297288
py_zi = py_zoneinfo.ZoneInfo(key)
298289
c_zi = c_zoneinfo.ZoneInfo(key)
@@ -334,7 +325,6 @@ def test_same_from_utc(self, dt, key):
334325
@hypothesis.example(dt=datetime.datetime.min, key="America/New_York")
335326
@hypothesis.example(dt=datetime.datetime.min, key="Asia/Tokyo")
336327
@hypothesis.example(dt=datetime.datetime.max, key="Asia/Tokyo")
337-
@mark_hypothesis
338328
def test_same_to_utc(self, dt, key):
339329
py_dt = dt.replace(tzinfo=py_zoneinfo.ZoneInfo(key))
340330
c_dt = dt.replace(tzinfo=c_zoneinfo.ZoneInfo(key))
@@ -362,7 +352,6 @@ def test_same_to_utc(self, dt, key):
362352

363353
@hypothesis.given(key=valid_keys())
364354
@add_key_examples
365-
@mark_hypothesis
366355
def test_cross_module_pickle(self, key):
367356
py_zi = py_zoneinfo.ZoneInfo(key)
368357
c_zi = c_zoneinfo.ZoneInfo(key)

0 commit comments

Comments
 (0)