advanced mocking of the builtin open() function in python