Skip to content

Commit

Permalink
Backwards compatibility fix for 3.8 and earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjw296 committed Jan 9, 2023
1 parent 18046f1 commit 5219601
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mock/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,16 @@ def _calls_repr(self, prefix="Calls"):
return f"\n{prefix}: {safe_repr(self.mock_calls)}."


try:
removeprefix = str.removeprefix
except AttributeError:
# Py 3.8 and earlier:
def removeprefix(name, prefix):
return name[len(prefix):]

# Denylist for forbidden attribute names in safe mode
_ATTRIB_DENY_LIST = frozenset({
name.removeprefix("assert_")
removeprefix(name, "assert_")
for name in dir(NonCallableMock)
if name.startswith("assert_")
})
Expand Down

0 comments on commit 5219601

Please sign in to comment.