[Tutor] Mock filesystem operations only for specific test doubles (was: mock file reader object)

2016-02-11 Thread Ben Finney
Anshu Kumar 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 https://pypi.python.org/pypi/gajja/>. Its FileDouble objects will allow fine-grained co

[Tutor] mock file reader object

2016-02-11 Thread Anshu Kumar
Hi, I need to mock file reader object , i tried using @patch('__builtin__.open') but it will patch my all file open readers. More precisely i have code something like below def restore_segments_and_lines_json(segments_file_path,lines_file_path,deleted_segment_ids): with open(segments_file_p

Re: [Tutor] mock

2016-01-23 Thread Peter Otten
Alex Kleider wrote: > Some weeks (perhaps months) ago, I posted a question about testing > and got many responses but had trouble grasping the concepts > so I settled on the suggestion that I thought would be the easiest > to implement (using unittest.mock.) Here it is- > > """ > from Peter Otten

[Tutor] mock

2016-01-22 Thread Alex Kleider
Some weeks (perhaps months) ago, I posted a question about testing and got many responses but had trouble grasping the concepts so I settled on the suggestion that I thought would be the easiest to implement (using unittest.mock.) Here it is- """ from Peter Otten: I find Ben's example instructive