From 9dfb1e5c38205e0066cb956b6f5af00ce7de4954 Mon Sep 17 00:00:00 2001 From: John Rouillard Date: Sun, 15 Dec 2024 02:34:57 -0500 Subject: [PATCH] fix(web) issue2551382 - case 1# or 1& failing. HAndle case for integer followed by a url delimiter. e.g. 1# and 1& --- test/test_liveserver.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/test_liveserver.py b/test/test_liveserver.py index cd62cd38..f4796856 100644 --- a/test/test_liveserver.py +++ b/test/test_liveserver.py @@ -26,7 +26,7 @@ # ruff: noqa: E402 from hypothesis import example, given, settings - from hypothesis.strategies import binary, characters, none, one_of, sampled_from, text + from hypothesis.strategies import binary, characters, emails, none, one_of, sampled_from, text except ImportError: from .pytest_patcher import mark_class @@ -48,7 +48,7 @@ def noop_strategy(*args, **kwargs): # define the decorator functions example = given = settings = noop_decorators_with_args # and stratgies using in decorators - binary = characters = none = one_of = sampled_from = text = noop_strategy + binary = characters = emails, none = one_of = sampled_from = text = noop_strategy try: @@ -213,6 +213,7 @@ class FuzzGetUrls(WsgiSetup, ClientSetup): @given(sampled_from(['@verbose', '@page_size', '@page_index']), one_of(characters(),text(min_size=1))) + @example("@verbose", "1#") @settings(max_examples=_max_examples, deadline=10000) # 10000ms def test_class_url_param_accepting_integer_values(self, param, value): @@ -224,10 +225,13 @@ def test_class_url_param_accepting_integer_values(self, param, value): query = '%s=%s' % (param, value) f = session.get(url, params=query) try: + # test case '0#' + if len(value) > 1 and value[-1] in ('#', '&'): + value = value[:-1] if int(value) >= 0: self.assertEqual(f.status_code, 200) except ValueError: - if value in ['#', '&']: + if value in ('#', '&'): self.assertEqual(f.status_code, 200) else: # invalid value for param @@ -235,6 +239,7 @@ def test_class_url_param_accepting_integer_values(self, param, value): @given(sampled_from(['@verbose']), one_of(characters(),text(min_size=1))) + @example("@verbose", "1#") @settings(max_examples=_max_examples, deadline=10000) # 10000ms def test_element_url_param_accepting_integer_values(self, param, value): @@ -246,6 +251,9 @@ def test_element_url_param_accepting_integer_values(self, param, value): query = '%s=%s' % (param, value) f = session.get(url, params=query) try: + # test case '0#' + if len(value) > 1 and value[-1] in ('#', '&'): + value = value[:-1] if int(value) >= 0: self.assertEqual(f.status_code, 200) except ValueError: @@ -255,7 +263,6 @@ def test_element_url_param_accepting_integer_values(self, param, value): # invalid value for param self.assertEqual(f.status_code, 400) - @skip_requests class BaseTestCases(WsgiSetup, ClientSetup): """Class with all tests to run against wsgi server. Is reused when