Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import unittest
import os
import io
import sys
import icartt
def compare_files(str_in, str_out, diff=0):
str_out.seek(0)
str_in.seek(0)
input = str_in.readlines()
output = str_out.readlines()
str_in.close()
str_out.close()
if not len(input) == len(output):
raise Exception("Input ({:d}) and output ({:d}) do not have the same number of lines!".format(len(input), len(output)))
for i in range(len(input)):
inline = input[i].strip().replace(" ", "")
outline = output[i].strip().replace(" ", "")
if not inline == outline:
print("Line {:d} differs:".format(i))
print(" input: {:s}".format(inline))
print(" output: {:s}".format(outline))
return True
class DatasetTestCase(unittest.TestCase):
def test_simple_1001_NOx(self):
fn = 'tests/examples/NOx_RHBrown_20040830_R0.ict'
print(fn)
str_in = open(fn)
str_out = io.StringIO()
ict = icartt.Dataset(fn, loadData=False)
ict.read_data()
ict.write(str_out)
assert compare_files(str_in, str_out)
def test_simple_1001_HOx(self):
fn = 'tests/examples/HOX_DC8_20040712_R0.ict'
print(fn)
str_in = open(fn)
str_out = io.StringIO()
ict = icartt.Dataset(fn, loadData=False)
ict.read_data()
ict.write(str_out)
assert compare_files(str_in, str_out)
def test_simple_2110_AR(self):
fn = 'tests/examples/AR_DC8_20050203_R0.ict'
print(fn)
str_in = open(fn)
str_out = io.StringIO()
ict = icartt.Dataset(fn, loadData=False)
ict.read_data()
ict.write(str_out)
assert compare_files(str_in, str_out)
def test_simple_2110_AROTAL(self):
fn = 'tests/examples/AROTAL-RAY_DC8_20040715_R1.ict'
print(fn)
str_in = open(fn)
str_out = io.StringIO()
ict = icartt.Dataset(fn, loadData=False)
ict.read_data()
ict.write(str_out)
assert compare_files(str_in, str_out)
def suite():
suite = unittest.TestSuite()
suite.addTest( DatasetTestCase('test_simple_1001_NOx') )
suite.addTest( DatasetTestCase('test_simple_1001_HOx') )
suite.addTest( DatasetTestCase('test_simple_2110_AR') )
suite.addTest( DatasetTestCase('test_simple_2110_AROTAL') )
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(suite())