Пример #1
0
 def exercise_write_and_seek(self):
     self.create_file_object(mode="wb")
     instrumented_file = mock.Mock(spec=self.file_object, wraps=self.file_object)
     report = ext.write_and_seek(ostream(instrumented_file))
     assert report == b""
     expected = b"1000 times 1000 equals 1000000"
     assert self.file_content() == expected
     assert self.file_object.tell() == 9
     if streambuf.default_buffer_size >= 30:
         assert instrumented_file.write.call_count == 1
     self.file_object.close()
Пример #2
0
 def exercise_write(self):
     self.create_file_object(mode="wb")
     report = ext.write_word(ostream(self.file_object))
     assert report == b""
     assert self.file_content() == b"2 times 1.6 equals 3.2"
     self.file_object.close()