Commit 4b576132 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: test output format specification

parent 9bd7c4eb
......@@ -17,6 +17,7 @@ import numpy as np
import pytest
import pandas as pd
from pandas.testing import assert_frame_equal
import funpack.main as main
import funpack.custom as custom
......@@ -1392,3 +1393,43 @@ def test_main_processing_basevid_fillval():
assert np.all(df1[df1 >= 75] * 100 == got1[got1 >= 75])
assert np.all(df2[df2 < 75] == got2[got2 < 75])
assert np.all(df2[df2 >= 75] * 100 == got2[got2 >= 75])
@patch_logging
def test_main_output_format():
with tempdir():
gen_test_data(10, 50, 'data.tsv')
exp = pd.read_csv('data.tsv', sep='\t', index_col=0)
# auto-detect output format
main.main('-ow out.tsv data.tsv'.split())
got = pd.read_csv('out.tsv', sep='\t', index_col=0)
assert_frame_equal(exp, got, check_dtype=False)
main.main('-ow out.csv data.tsv'.split())
with open('out.csv') as f:
print(f.readline())
got = pd.read_csv('out.csv', sep=',', index_col=0)
assert_frame_equal(exp, got, check_dtype=False)
main.main('-ow out.h5 data.tsv'.split())
got = pd.read_hdf('out.h5')
assert_frame_equal(exp, got, check_dtype=False)
# specify output format
main.main('-ow -f tsv out data.tsv'.split())
got = pd.read_csv('out', sep='\t', index_col=0)
assert_frame_equal(exp, got, check_dtype=False)
main.main('-ow -f tsv out.csv data.tsv'.split())
got = pd.read_csv('out.csv', sep='\t', index_col=0)
assert_frame_equal(exp, got, check_dtype=False)
main.main('-ow -f csv out.tsv data.tsv'.split())
got = pd.read_csv('out.tsv', sep=',', index_col=0)
assert_frame_equal(exp, got, check_dtype=False)
main.main('-ow -f hdf5 out.bin data.tsv'.split())
got = pd.read_hdf('out.bin')
assert_frame_equal(exp, got, check_dtype=False)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment