source: nappy/trunk/nappy/unit_tests/test_na_file_2160.py @ 3355

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

Improved tests code.

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