Skip to content

Commit

Permalink
Move helper fn to compat.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Sep 2, 2023
1 parent c0a60d7 commit 8ca6c34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 1 addition & 9 deletions hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from hypothesis.internal.compat import (
PYPY,
BaseExceptionGroup,
add_note,
bad_django_TestCase,
get_type_hints,
int_from_bytes,
Expand Down Expand Up @@ -1008,15 +1009,6 @@ def run_engine(self):
_raise_to_user(errors_to_report, self.settings, report_lines)


def add_note(exc, note):
try:
exc.add_note(note)
except AttributeError:
if not hasattr(exc, "__notes__"):
exc.__notes__ = []
exc.__notes__.append(note)


def _raise_to_user(errors_to_report, settings, target_lines, trailer=""):
"""Helper function for attaching notes and grouping multiple errors."""
failing_prefix = "Falsifying example: "
Expand Down
9 changes: 9 additions & 0 deletions hypothesis-python/src/hypothesis/internal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
WINDOWS = platform.system() == "Windows"


def add_note(exc, note):
try:
exc.add_note(note)
except AttributeError:
if not hasattr(exc, "__notes__"):
exc.__notes__ = []
exc.__notes__.append(note)


def escape_unicode_characters(s: str) -> str:
return codecs.encode(s, "unicode_escape").decode("ascii")

Expand Down

0 comments on commit 8ca6c34

Please sign in to comment.