Last change
on this file since 7767 was
7762,
checked in by James Hudson, 15 years ago
|
All tests in file module pass.
|
File size:
1.0 KB
|
Line | |
---|
1 | import os |
---|
2 | import unittest |
---|
3 | import tempfile |
---|
4 | import numpy as num |
---|
5 | |
---|
6 | from csv_file import load_csv_as_array, load_csv_as_dict |
---|
7 | |
---|
8 | |
---|
9 | class Test_csv(unittest.TestCase): |
---|
10 | def setUp(self): |
---|
11 | pass |
---|
12 | |
---|
13 | def tearDown(self): |
---|
14 | pass |
---|
15 | |
---|
16 | def test_get_data_from_file1(self): |
---|
17 | fileName = tempfile.mktemp(".txt") |
---|
18 | # print"filename",fileName |
---|
19 | file = open(fileName,"w") |
---|
20 | file.write("elevation stage\n\ |
---|
21 | 1.3 3 \n\ |
---|
22 | 0.0 4 \n\ |
---|
23 | 4.5 3.5 \n\ |
---|
24 | 1.0 6 \n") |
---|
25 | file.close() |
---|
26 | |
---|
27 | x = load_csv_as_array(fileName, delimiter=' ') |
---|
28 | |
---|
29 | # header, x = load_csv_as_array(fileName, delimiter=' ') |
---|
30 | os.remove(fileName) |
---|
31 | |
---|
32 | assert num.allclose(x['elevation'], [1.3, 0.0,4.5, 1.0]) |
---|
33 | assert num.allclose(x['stage'], [3.0, 4.0,3.5, 6.0]) |
---|
34 | |
---|
35 | |
---|
36 | ################################################################################# |
---|
37 | |
---|
38 | if __name__ == "__main__": |
---|
39 | suite = unittest.makeSuite(Test_csv, 'test') |
---|
40 | runner = unittest.TextTestRunner(verbosity=1) |
---|
41 | runner.run(suite) |
---|
Note: See
TracBrowser
for help on using the repository browser.