source: nappy/trunk/nappy/unit_tests/test_na_file_1010.py @ 3414

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/unit_tests/test_na_file_1010.py@3414
Revision 3414, 1.1 KB checked in by astephen, 12 years ago (diff)

Tidied up _fixHeaderLength in na_file.py.
Changed write interface so self.write(na_dict, delimiter, float_format)
is a separate call to creating the instance.
Fixed unit tests to cope with this.

BUT: broke nappy_api.openNAFile(<file>, "w") with these changes.
Hence need to think about changes being made to openNAFile() so that it
can predict (or not) the FFI.

Only 1001 unit test (worked on by CK) is broken at present.

Line 
1"""
2test_na_file_1010.py
3====================
4
5Tests for the na_file_1010.py module.
6
7"""
8
9# Import standard library modules
10import unittest
11import os
12import sys
13
14# Import local modules
15base_dir = os.environ.get("NAPPY_BASE_DIR", "../..")
16sys.path.append(base_dir)
17
18import nappy
19import nappy.na_file.na_file_1010
20
21class NAFile1010_TestCase(unittest.TestCase):
22
23    def setUp(self):
24        self.infile = os.path.join(base_dir, "data_files", "1010.na")
25        self.outfile = os.path.join(base_dir, "test_outputs", "test_1010.na")
26        self.fin = nappy.openNAFile(self.infile)
27        self.fin.readData()
28        self.na_dict = self.fin.getNADict()       
29
30    def test_read1010(self):
31        "Tests reading FFI 1010."
32        self.assertEqual(type(self.na_dict), type({1:2}))
33
34    def test_write1010(self):
35        "Tests writing FFI 1010."
36        self.fobj = nappy.na_file.na_file_1010.NAFile1010(self.outfile, mode="w")               
37        self.fobj.write(na_dict=self.na_dict)
38        self.failUnless(isinstance(self.fobj, nappy.na_file.na_file.NAFile))
39
40if __name__ ==  "__main__":
41
42    unittest.main()
43
44
Note: See TracBrowser for help on using the repository browser.