Skip to content
Myr

Better not call it `chr`, rename to `byteschr`.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Martijn Pieters · committed by Martijn Pieters · parent a4be9a2 · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • tests:+4 added−2 removed

1 file+4 added−2 removed

modified:tests/test_utils.py+4 added-2 removed
12 unmodified lines
131415if is_py3:16 unichr = chr17 chr = lambda c: bytes([c])17 byteschr = lambda c: bytes([c])18else:19 byteschr = chr202122class GuessJSONUTFTests(unittest.TestCase):23 """Tests for the JSON UTF encoding guessing code."""
20 unmodified lines
44 # is a test failure.45 guess = requests.utils.guess_json_utf46 for i in range(1000):47 sample = bytes().join(46 [chr(random.randrange(256)) for _ in range(4)])48 [byteschr(random.randrange(256)) for _ in range(4)])49 res = guess(sample)50 if res is not None and res != 'utf-8':51 # This should decode without errors if this is *really*52 # something in this encoding. Skip UTF-8, it is more
6 unmodified lines