Mercurial > p > roundup > code
comparison test/test_liveserver.py @ 8215:1b15f635ada1
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
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 16 Dec 2024 19:19:07 -0500 |
| parents | 55b0abde56ab |
| children | 03020f08a685 |
comparison
equal
deleted
inserted
replaced
| 8214:55b0abde56ab | 8215:1b15f635ada1 |
|---|---|
| 23 try: | 23 try: |
| 24 import hypothesis | 24 import hypothesis |
| 25 skip_hypothesis = lambda func, *args, **kwargs: func | 25 skip_hypothesis = lambda func, *args, **kwargs: func |
| 26 | 26 |
| 27 # ruff: noqa: E402 | 27 # ruff: noqa: E402 |
| 28 from hypothesis import example, given, settings | 28 from hypothesis import example, given, reproduce_failure, settings |
| 29 from hypothesis.strategies import binary, characters, emails, none, one_of, sampled_from, text | 29 from hypothesis.strategies import binary, characters, emails, none, one_of, sampled_from, text |
| 30 | 30 |
| 31 except ImportError: | 31 except ImportError: |
| 32 from .pytest_patcher import mark_class | 32 from .pytest_patcher import mark_class |
| 33 skip_hypothesis = mark_class(pytest.mark.skip( | 33 skip_hypothesis = mark_class(pytest.mark.skip( |
| 44 # define a dummy strategy | 44 # define a dummy strategy |
| 45 def noop_strategy(*args, **kwargs): | 45 def noop_strategy(*args, **kwargs): |
| 46 pass | 46 pass |
| 47 | 47 |
| 48 # define the decorator functions | 48 # define the decorator functions |
| 49 example = given = settings = noop_decorators_with_args | 49 example = given = reproduce_failure = settings = noop_decorators_with_args |
| 50 # and stratgies using in decorators | 50 # and stratgies using in decorators |
| 51 binary = characters = emails, none = one_of = sampled_from = text = noop_strategy | 51 binary = characters = emails, none = one_of = sampled_from = text = noop_strategy |
| 52 | 52 |
| 53 | 53 |
| 54 try: | 54 try: |
| 235 self.assertEqual(f.status_code, 200) | 235 self.assertEqual(f.status_code, 200) |
| 236 else: | 236 else: |
| 237 # invalid value for param | 237 # invalid value for param |
| 238 self.assertEqual(f.status_code, 400) | 238 self.assertEqual(f.status_code, 400) |
| 239 | 239 |
| 240 @given(sampled_from(['@verbose']), | 240 @given(sampled_from(['@verbose']), text(min_size=1)) |
| 241 one_of(characters(),text(min_size=1))) | |
| 242 @example("@verbose", "1#") | 241 @example("@verbose", "1#") |
| 243 @settings(max_examples=_max_examples, | 242 @settings(max_examples=_max_examples, |
| 244 deadline=10000) # 10000ms | 243 deadline=10000) # 10000ms |
| 245 def test_element_url_param_accepting_integer_values(self, param, value): | 244 def test_element_url_param_accepting_integer_values(self, param, value): |
| 246 """Tests all integer args for rest url. @page_* is the | 245 """Tests all integer args for rest url. @page_* is the |
