|
24 | 24 | import traceback
|
25 | 25 | import warnings
|
26 | 26 | import zlib
|
| 27 | +from inspect import getfullargspec |
| 28 | +from io import StringIO |
27 | 29 | from random import Random
|
28 | 30 | from unittest import TestCase
|
29 | 31 |
|
|
54 | 56 | )
|
55 | 57 | from hypothesis.executors import new_style_executor
|
56 | 58 | from hypothesis.internal.compat import (
|
57 |
| - PY2, |
58 | 59 | bad_django_TestCase,
|
59 | 60 | benchmark_time,
|
60 |
| - binary_type, |
61 | 61 | get_type_hints,
|
62 |
| - getfullargspec, |
63 |
| - hbytes, |
64 | 62 | int_from_bytes,
|
65 | 63 | qualname,
|
66 | 64 | )
|
|
95 | 93 | SearchStrategy,
|
96 | 94 | )
|
97 | 95 | from hypothesis.utils.conventions import infer
|
98 |
| -from hypothesis.vendor.pretty import CUnicodeIO, RepresentationPrinter |
| 96 | +from hypothesis.vendor.pretty import RepresentationPrinter |
99 | 97 | from hypothesis.version import __version__
|
100 | 98 |
|
101 | 99 | if False:
|
@@ -182,9 +180,7 @@ def accept(test):
|
182 | 180 |
|
183 | 181 |
|
184 | 182 | def encode_failure(buffer):
|
185 |
| - # This needs to be a real bytes() instance, so we use binary_type() |
186 |
| - # instead of hbytes() here. |
187 |
| - buffer = binary_type(buffer) |
| 183 | + buffer = bytes(buffer) |
188 | 184 | compressed = zlib.compress(buffer)
|
189 | 185 | if len(compressed) < len(buffer):
|
190 | 186 | buffer = b"\1" + compressed
|
@@ -308,10 +304,7 @@ class ArtificialDataForExample(ConjectureData):
|
308 | 304 | def __init__(self, kwargs):
|
309 | 305 | self.__draws = 0
|
310 | 306 | self.__kwargs = kwargs
|
311 |
| - |
312 |
| - super().__init__( |
313 |
| - max_length=0, prefix=hbytes(), random=None, |
314 |
| - ) |
| 307 | + super().__init__(max_length=0, prefix=b"", random=None) |
315 | 308 |
|
316 | 309 | def draw_bits(self, n):
|
317 | 310 | raise NotImplementedError() # pragma: no cover
|
@@ -562,7 +555,7 @@ def run(data):
|
562 | 555 | text_repr[0] = arg_string(test, args, kwargs)
|
563 | 556 |
|
564 | 557 | if print_example or current_verbosity() >= Verbosity.verbose:
|
565 |
| - output = CUnicodeIO() |
| 558 | + output = StringIO() |
566 | 559 |
|
567 | 560 | printer = RepresentationPrinter(output)
|
568 | 561 | if print_example:
|
@@ -1088,18 +1081,8 @@ def wrapped_test(*arguments, **kwargs):
|
1088 | 1081 | # full of Hypothesis internals they don't care about.
|
1089 | 1082 | # We have to do this inline, to avoid adding another
|
1090 | 1083 | # internal stack frame just when we've removed the rest.
|
1091 |
| - if PY2: |
1092 |
| - # Python 2 doesn't have Exception.with_traceback(...); |
1093 |
| - # instead it has a three-argument form of the `raise` |
1094 |
| - # statement. Unfortunately this is a SyntaxError on |
1095 |
| - # Python 3, and before Python 2.7.9 it was *also* a |
1096 |
| - # SyntaxError to use it in a nested function so we |
1097 |
| - # can't `exec` or `eval` our way out (BPO-21591). |
1098 |
| - # So unless we break some versions of Python 2, none |
1099 |
| - # of them get traceback elision. |
1100 |
| - raise |
1101 |
| - # On Python 3, we swap out the real traceback for our |
1102 |
| - # trimmed version. Using a variable ensures that the line |
| 1084 | + # |
| 1085 | + # Using a variable for our trimmed error ensures that the line |
1103 | 1086 | # which will actually appear in tracebacks is as clear as
|
1104 | 1087 | # possible - "raise the_error_hypothesis_found".
|
1105 | 1088 | the_error_hypothesis_found = e.with_traceback(
|
|
0 commit comments