Python HTTP Post method returns response as magicmock object instead of value

I am trying to check the response status code after trigerring some API with a POST method, Response status code is of Magicmock instance type, i am checking whether the status code is inbetween 400 and 500 using comparison operator which works in python 2 but raises TypeError in python 3 import

mock file open in python

I'm trying to mock file open, and all of the examples show that I need to @patch('open', create=True) but I keep getting Need a valid target to patch. You supplied: 'open' I know patch needs the full dotted path of open , but I have no idea what it is. As a matter of fact, I'm not even sure that's