Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ def num_mock_patch_args(function):
if any(mock_modules):
sentinels = [m.DEFAULT for m in mock_modules if m is not None]
return len(
[p for p in patchings if not p.attribute_name and p.new in sentinels]
[
p
for p in patchings
if not p.attribute_name
and any(p.new is s for s in sentinels)
]
)
return len(patchings)

Expand Down
15 changes: 15 additions & 0 deletions testing/test_patch_array_sentinel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest.mock import patch


class WeirdEq:
class Amb:
def __bool__(self):
raise ValueError("ambiguous truth")

def __eq__(self, other):
return WeirdEq.Amb()


@patch("os.path.abspath", new=WeirdEq())
def test_collect_ok():
assert True