Skip to content

Commit 89c9814

Browse files
committed
fix(web) issue2551382 - handle crash in request call in test
due to invalid utf8 with surrogate. Ci reports this failure in the requests call from the test case: > string = string.encode(encoding, errors) E UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 48: surrogates not allowed E Falsifying example: test_class_url_param_accepting_integer_values( E self=<test.test_liveserver.FuzzGetUrls testMethod=test_class_url_param_accepting_integer_values>, E param='@verbose', # or any other generated value E value='\ud800', E ) E Explanation: E These lines were always and only run by failing examples: E /opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/site-packages/requests/utils.py:675 E E You can reproduce this example by temporarily adding @reproduce_failure('6.122.3', b'AAAAAQDXAA==') as a decorator on your test case
1 parent 9dfb1e5 commit 89c9814

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/test_liveserver.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
skip_hypothesis = lambda func, *args, **kwargs: func
2626

2727
# ruff: noqa: E402
28-
from hypothesis import example, given, settings
28+
from hypothesis import example, given, reproduce_failure, settings
2929
from hypothesis.strategies import binary, characters, emails, none, one_of, sampled_from, text
3030

3131
except ImportError:
@@ -46,7 +46,7 @@ def noop_strategy(*args, **kwargs):
4646
pass
4747

4848
# define the decorator functions
49-
example = given = settings = noop_decorators_with_args
49+
example = given = reproduce_failure = settings = noop_decorators_with_args
5050
# and stratgies using in decorators
5151
binary = characters = emails, none = one_of = sampled_from = text = noop_strategy
5252

@@ -237,8 +237,7 @@ def test_class_url_param_accepting_integer_values(self, param, value):
237237
# invalid value for param
238238
self.assertEqual(f.status_code, 400)
239239

240-
@given(sampled_from(['@verbose']),
241-
one_of(characters(),text(min_size=1)))
240+
@given(sampled_from(['@verbose']), text(min_size=1))
242241
@example("@verbose", "1#")
243242
@settings(max_examples=_max_examples,
244243
deadline=10000) # 10000ms

0 commit comments

Comments
 (0)