Ignore:
Timestamp:
17/03/08 14:20:36 (12 years ago)
Author:
astephen
Message:

Cleaned up some of the data files and improved unit tests and comparison code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/nappy/unit_tests/test_na_file_2110.py

    r3529 r3625  
    2525        self.outfile = os.path.join(base_dir, "test_outputs", "test_2110.na") 
    2626        self.out_csv = os.path.join(base_dir, "test_outputs", "test_2110.csv") 
     27        self.out_csv_annotated = os.path.join(base_dir, "test_outputs", "test_2110_annotated.csv") 
    2728        self.fin = nappy.openNAFile(self.infile) 
    2829        self.fin.readData() 
     
    3940        self.failUnless(isinstance(fobj, nappy.na_file.na_file.NAFile)) 
    4041 
     42    def test_writeCSV2110(self): 
     43        "Tests conversion to CSV." 
     44        fobj = nappy.openNAFile(self.out_csv, mode="w", na_dict=self.na_dict) 
     45        fobj.write(delimiter=",", float_format="%.2d") 
     46        self.failUnless(isinstance(fobj, nappy.na_file.na_file.NAFile)) 
     47 
    4148    def test_writeAnnotatedCSV2110(self): 
    42         "Tests conversion to NetCDF." 
    43         fobj = nappy.openNAFile(self.out_csv, mode="w", na_dict=self.na_dict) 
    44         fobj.write(delimiter=",", float_format="%.2d", annotation=True) 
     49        "Tests conversion to Annotated CSV." 
     50        fobj = nappy.openNAFile(self.out_csv_annotated, mode="w", na_dict=self.na_dict) 
     51        fobj.write(delimiter=",", annotation=True) 
    4552        self.failUnless(isinstance(fobj, nappy.na_file.na_file.NAFile)) 
    4653  
    4754    def test_compareFiles2110(self): 
    4855        "Tests comparison of written and original files for equivalence." 
    49         res = nappy.utils.compare_na.compNAFiles(self.infile, self.outfile) 
     56        res = nappy.utils.compare_na.compNAFiles(self.infile, self.outfile, approx_equal=True) 
    5057        self.assertEqual(res, True) 
    51          
     58        
     59    def test_compareNAToCSV2110(self): 
     60        "Tests comparison of original and CSV version written."  
     61        res = nappy.utils.compare_na.compNAFiles(self.infile, self.out_csv, delimiter_2=",") 
     62        self.assertEqual(res, True) 
     63 
    5264 
    5365if __name__ ==  "__main__": 
Note: See TracChangeset for help on using the changeset viewer.