source: CCCC/trunk/unitTestsS2.py @ 100

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CCCC/trunk/unitTestsS2.py@100
Revision 100, 1.0 KB checked in by mjuckes, 7 years ago (diff)

fixed leaking of log file handles

Line 
1
2import logging, time
3import utils_c4
4import config_c4 as config
5from c4 import fileMetadata, dummy
6
7#### set up log file ####
8tstring2 = '%4.4i%2.2i%2.2i' % time.gmtime()[0:3]
9testLogFile = '%s__qclog_%s.txt' % ('unitTestsS2',tstring2)
10log = logging.getLogger(testLogFile)
11fHdlr = logging.FileHandler(testLogFile,mode='w')
12fileFormatter = logging.Formatter('%(message)s')
13fHdlr.setFormatter(fileFormatter)
14log.addHandler(fHdlr)
15log.setLevel(logging.INFO)
16
17try:
18  fmd = fileMetadata(dummy=True)
19  fmd.loadNc( '/dummyPath/v1_day_a_b_1990-1991.nc')
20except:
21  print 'Failed to parse a simple dummy file path'
22  raise
23print 'OK: instantiated fileMetaData and parsed a simple dummy path'
24
25p = dummy()
26p.log = log
27p.pcfg = config.projectConfig( "__dummy" )
28
29
30module = 'checkFileName'
31c = utils_c4.checkFileName(parent=p)
32
33fn = 'v1_t1_a_b_20060101-20101231.nc'
34testId = '#01.001'
35c.check( fn )
36if c.errorCount == 0:
37  print 'Passed [%s] %s: valid file name' % (module,fn)
38else:
39  print 'Failed [%s] %s: valid file name' % (module,fn)
Note: See TracBrowser for help on using the repository browser.