annotate tests/test_read.py @ 74:e21021ca3907

add tests for reader
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:28:58 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 we need a simple data reader; let's test it!
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 # See also and to combine with:
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 # http://k0s.org/hg/numerics/file/tip/numerics/read.py
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import os
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 import unittest
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 from tvii.read import read
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 here = os.path.dirname(os.path.abspath(__file__))
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 data = os.path.join(here, 'data')
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 class TestReadData(unittest.TestCase):
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 def test_csv_vs_tsv(self):
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 """really, not tsv; its actually space separated"""
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 csv_file = os.path.join(data, 'linear.csv')
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 csv_array = read(csv_file)
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 tsv_file = os.path.join(data, 'linear.tsv')
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 tsv_array = read(tsv_file)
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 assert tsv_array == csv_array
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 if __name__ == '__main__':
e21021ca3907 add tests for reader
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32 main()