Reputation: 3495
I'm trying to monkeypatch in pytest the input function to simulate user input but I'm getting an attribute error.
I receive the same error when I use the mock.patch.object as well. But I'm able to readily monkeypatch the input when I'm in a regular Python environment, I only get this error in testing.
What could be causing this issue?
Edit
Adding additional screenshot trying same thing using unittest.mock
Upvotes: 0
Views: 622
Reputation: 280778
__builtins__
is an implementation detail. You shouldn't touch it. What you're looking for is either the __builtin__
(no s
) or builtins
module, depending on whether you're on Python 2 or 3.
Judging by the details of the error you got, you're on Python 3, so you want builtins
.
Upvotes: 3