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