def _test_success_flush(): builder = SmallBodiesFileBuilder(self.FILEPATH) builder.create_small_body_file() builder.add_body(1, [1., 2., 3., 4., 5., 6., 7.]) builder.flush() with open(self.FILEPATH) as f: total_lines_count = sum(1 for _ in f) self.assertEqual(total_lines_count, 7) os.remove(self.FILEPATH)
def _test_file_existance(): builder = SmallBodiesFileBuilder(self.FILEPATH) builder.add_body(1, [1., 2., 3., 4., 5., 6., 7.]) with self.assertRaises(FileNotFoundError): builder.flush()