Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _write_test(self, table, expected, dialect="excel", transpose=False):
tmpfd, tmpfname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv")
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)
def _df_test(self, table, dialect, **kwargs):
tmpfd, tmpfname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv")
tmpid = os.fdopen(tmpfd, "w")
w = writer(tmpid, dialect=dialect)
w.writerows(table)
tmpid.close()
exp_df = pd.DataFrame.from_records(table[1:], columns=table[0])
df = wrappers.csv2df(tmpfname)
try:
self.assertTrue(df.equals(exp_df))
finally:
os.unlink(tmpfname)
def _df_test(self, table, dialect, **kwargs):
tmpfd, tmpfname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv")
tmpid = os.fdopen(tmpfd, "w")
w = writer(tmpid, dialect=dialect)
w.writerows(table)
tmpid.close()
exp_df = pd.DataFrame.from_records(table[1:], columns=table[0])
df = wrappers.csv2df(tmpfname)
try:
self.assertTrue(df.equals(exp_df))
finally:
os.unlink(tmpfname)
def _write_test(self, table, expected, dialect="excel", transpose=False):
tmpfd, tmpfname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv")
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)