Commit 553d1c5f authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Make sure error is raised on bad input

parent bba1a417
......@@ -1338,3 +1338,76 @@ def test_main_indexes():
expdf.columns = expcols
assert np.all(df[expcols] == expdf[expcols])
@patch_logging
def test_main_bad_inputs():
data = tw.dedent("""
eid,col1
1,10
2,20
3,30
4,40
5,50
""")
badfile1 = tw.dedent("""
a
1
2
3
""")
badfile2 = tw.dedent("""
1
a
3
""")
with tempdir():
with open('data.txt', 'wt') as f: f.write(data)
with open('badfile1.txt', 'wt') as f: f.write(badfile1)
with open('badfile2.txt', 'wt') as f: f.write(badfile2)
with pytest.raises(Exception):
main.main('out.tsv nofile')
with pytest.raises(Exception):
main.main('-v foo out.tsv data.txt')
with pytest.raises(Exception):
main.main('-v 1,foo,3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-v 1:foo:3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-v nofile out.tsv data.txt')
with pytest.raises(Exception):
main.main('-v badfile1.txt sout.tsv data.txt')
with pytest.raises(Exception):
main.main('-v badfile2.txt sout.tsv data.txt')
with pytest.raises(Exception):
main.main('-s foo out.tsv data.txt')
with pytest.raises(Exception):
main.main('-s 1,foo,3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-s 1:foo:3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-s nofile out.tsv data.txt')
with pytest.raises(Exception):
main.main('-s badfile1.txt sout.tsv data.txt')
with pytest.raises(Exception):
main.main('-s badfile2.txt sout.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex foo out.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex 1,foo,3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex 1:foo:3 out.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex nofile out.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex badfile1.txt sout.tsv data.txt')
with pytest.raises(Exception):
main.main('-ex badfile2.txt sout.tsv data.txt')
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