def test_write_invalid_alignment(self): for invalid_obj, error_msg_regexp in self.invalid_objs: fh = io.StringIO() with self.assertRaisesRegex(PhylipFormatError, error_msg_regexp): _tabular_msa_to_phylip(invalid_obj, fh) # ensure nothing was written to the file before the error was # thrown obs = fh.getvalue() fh.close() self.assertEqual(obs, '')
def test_write(self): for fp, obj in zip(self.fps, self.objs): fh = io.StringIO() _tabular_msa_to_phylip(obj, fh) obs = fh.getvalue() fh.close() with io.open(fp) as fh: exp = fh.read() self.assertEqual(obs, exp)