[Tutor] Mock filesystem operations only for specific test doubles (was: mock file reader object)
ben+python at benfinney.id.au
Thu Feb 11 16:32:08 EST 2016
Anshu Kumar <anshu.kumar726 at gmail.com> writes:
> I need to mock file reader object , i tried using
> @patch('__builtin__.open') but it will patch my all file open readers.
For this reason I have written and published the Gajja library
Its FileDouble objects will allow fine-grained control over exactly
which file accesses are mocked, leaving the rest to behave normally.
To date it is only used in one code base. I would be pleased to receive
feedback either to my email address or at the “testing in Python” forum
\ “I never forget a face, but in your case I'll be glad to make |
`\ an exception.” —Groucho Marx |
More information about the Tutor