Skip to content

Commit 98dbe9f

Browse files
committed
test: Override Fuzz timeout from env variable.
I have a local pytest.ini where I use: env = pytest_fuzz_timeout=30000 to set a 30 second timout while keeping the default 10 second for CI because my machine is slow. So the test now looks for that env variable and uses it if set.
1 parent 8c2fe02 commit 98dbe9f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/test_liveserver.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,17 @@ class FuzzGetUrls(WsgiSetup, ClientSetup):
225225

226226
_max_examples = 100
227227

228+
# Timeout for each fuzz test in ms. Use env variable in local
229+
# pytest.ini if your dev environment can't complete in the default
230+
# 10 seconds.
231+
fuzz_deadline = int(os.environ.get('pytest_fuzz_timeout', 0)) or 10000
232+
228233
@given(sampled_from(['@verbose', '@page_size', '@page_index']),
229234
text(min_size=1))
230235
@example("@verbose", "1#")
231236
@example("@verbose", "#1stuff")
232237
@settings(max_examples=_max_examples,
233-
deadline=10000) # in ms
238+
deadline=fuzz_deadline) # in ms
234239
def test_class_url_param_accepting_integer_values(self, param, value):
235240
"""Tests all integer args for rest url. @page_* is the
236241
same code for all *.
@@ -258,7 +263,7 @@ def test_class_url_param_accepting_integer_values(self, param, value):
258263
@example("@verbose", "10#")
259264
@example("@verbose", u'Ø\U000dd990')
260265
@settings(max_examples=_max_examples,
261-
deadline=10000) # in ms
266+
deadline=fuzz_deadline) # in ms
262267
def test_element_url_param_accepting_integer_values(self, param, value):
263268
"""Tests args accepting int for rest url.
264269
"""
@@ -281,10 +286,20 @@ def test_element_url_param_accepting_integer_values(self, param, value):
281286
# invalid value for param
282287
self.assertEqual(f.status_code, 400)
283288

289+
@skip_hypothesis
290+
class FuzzTestSettingData(WsgiSetup, ClientSetup):
291+
292+
_max_examples = 100
293+
294+
# Timeout for each fuzz test in ms. Use env variable in local
295+
# pytest.ini if your dev environment can't complete in the default
296+
# 10 seconds.
297+
fuzz_deadline = int(os.environ.get('pytest_fuzz_timeout', 0)) or 10000
298+
284299
@given(emails())
285300
@settings(max_examples=_max_examples,
286-
deadline=10000) # in ms
287-
def test_email_param(self,email):
301+
deadline=fuzz_deadline) # in ms
302+
def test_setting_email_param(self,email):
288303
session, _response = self.create_login_session()
289304
url = '%s/rest/data/user/1/address' % (self.url_base())
290305
headers = {"Accept": "application/json",

0 commit comments

Comments
 (0)