def file_handling():
temp_file = open("/root/temp.tmp", 'w')
temp_file.write("a")
temp_file.write("b")
How to mock the 'open' method and subsequent write statements here? When i checked the solution online, suggestions were to use mock_open using the mock library. How can i make use of that here?
self.stubs.Set(__builtins__, "open", lambda *args: <some obj>) does not seem to work.