source: nappy/trunk/nappy/unit_tests/test_na_file_2010.py @ 3353

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/unit_tests/test_na_file_2010.py@3353
Revision 3353, 1.1 KB checked in by astephen, 12 years ago (diff)
RevLine 
[3339]1"""
2test_na_file_2010.py
[3353]3====================
[3339]4
5Tests for the na_file_2010.py module.
6
7"""
8
9# Import standard library modules
10import unittest
[3353]11import os
12import sys
[3339]13
14# Import local modules
[3353]15os.environ["NAPPY_BASE_DIR"] = "..\\.."
16base_dir = os.environ["NAPPY_BASE_DIR"]
17sys.path.append(base_dir)
[3339]18
[3353]19import nappy
20import nappy.na_file.na_file
[3339]21
[3353]22class NAFile2010_TestCase(unittest.TestCase):
23
[3339]24    def setUp(self):
[3353]25        self.infile = os.path.join(base_dir, "data_files", "2010.na")
26        self.outfile = os.path.join(base_dir, "test_outputs", "test_2010.na")
27        self.fin = nappy.openNAFile(self.infile)
28        self.fin.readData()
29        self.na_dict = self.fin.getNADict()       
[3339]30
[3353]31    def test_read2010(self):
32        "Tests reading FFI 2010."
33        self.assertEqual(type(self.na_dict), type({1:2}))
[3339]34
[3353]35    def test_write2010(self):
36        "Tests writing FFI 2010."
37        self.fobj = nappy.openNAFile(self.outfile, mode="w", na_dict=self.na_dict)             
38        self.failUnless(isinstance(self.fobj, nappy.na_file.na_file.NAFile))
[3339]39
40if __name__ ==  "__main__":
41
42    unittest.main()
43
Note: See TracBrowser for help on using the repository browser.