def _write_test(self, table, expected, **kwargs): tmpfd, tmpfname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv") wrappers.write_table(table, tmpfname, **kwargs) read_encoding = kwargs.get("encoding", None) with open(tmpfname, "r", newline="", encoding=read_encoding) as fp: data = fp.read() try: self.assertEqual(data, expected) finally: os.close(tmpfd) os.unlink(tmpfname)
def _write_test(self, table, expected, dialect="excel", transpose=False): tmpfd, tmpfname = tempfile.mkstemp() wrappers.write_table( table, tmpfname, dialect=dialect, transpose=transpose ) with open(tmpfname, "r") as fp: data = fp.read() try: self.assertEqual(data, expected) finally: os.close(tmpfd) os.unlink(tmpfname)