Commit effb30e5eded0b1f98c8d45dfe5d1d7a71681b69
Committed by
Jürgen Knödlseder
1 parent
71ddf47a
modif of the test_ctfindvar to test the output file (#2713)
Showing
1 changed file
with
28 additions
and
32 deletions
test/test_ctfindvar.py
| @@ -97,7 +97,7 @@ class Test(test): | @@ -97,7 +97,7 @@ class Test(test): | ||
| 97 | """ | 97 | """ |
| 98 | Test ctfindvar from Python | 98 | Test ctfindvar from Python |
| 99 | """ | 99 | """ |
| 100 | - print "here in the python test" | 100 | + |
| 101 | # Allocate ctfindvar | 101 | # Allocate ctfindvar |
| 102 | ctfindvar = ctools.ctfindvar() | 102 | ctfindvar = ctools.ctfindvar() |
| 103 | 103 | ||
| @@ -105,7 +105,7 @@ class Test(test): | @@ -105,7 +105,7 @@ class Test(test): | ||
| 105 | ctfindvar['inobs'] = self._events | 105 | ctfindvar['inobs'] = self._events |
| 106 | ctfindvar['logfile'] = 'ctfindvar_py0.log' | 106 | ctfindvar['logfile'] = 'ctfindvar_py0.log' |
| 107 | ctfindvar['chatter'] = 1 | 107 | ctfindvar['chatter'] = 1 |
| 108 | - ctfindvar['prefix'] = 'ctfindvar_test_' | 108 | + ctfindvar['prefix'] = 'ctfindvar_test_python_' |
| 109 | ctfindvar['histtype'] = 'FITS' | 109 | ctfindvar['histtype'] = 'FITS' |
| 110 | ctfindvar['tmin'] = 'NONE' | 110 | ctfindvar['tmin'] = 'NONE' |
| 111 | ctfindvar['tmax'] = 'NONE' | 111 | ctfindvar['tmax'] = 'NONE' |
| @@ -124,45 +124,40 @@ class Test(test): | @@ -124,45 +124,40 @@ class Test(test): | ||
| 124 | ctfindvar['caldb'] = 'prod2' | 124 | ctfindvar['caldb'] = 'prod2' |
| 125 | ctfindvar['irf'] = 'South_0.5h' | 125 | ctfindvar['irf'] = 'South_0.5h' |
| 126 | 126 | ||
| 127 | - ## Check that saving does not nothing | ||
| 128 | - #ctfindvar['logfile'] = 'ctfindvar_py0.log' | ||
| 129 | - #ctfindvar.logFileOpen() | ||
| 130 | - #ctfindvar.save() | ||
| 131 | - #self.test_assert(not os.path.isfile('ctfindvar_test_srcsig.fits'), | ||
| 132 | - # 'Check that no FITS file has been created') | ||
| 133 | - | ||
| 134 | - | ||
| 135 | ## Run ctfindvar tool | 127 | ## Run ctfindvar tool |
| 136 | - #ctfindvar.logFileOpen() | 128 | + ctfindvar.logFileOpen() |
| 137 | ctfindvar.run() | 129 | ctfindvar.run() |
| 138 | 130 | ||
| 139 | - ## Check result | ||
| 140 | - #self._check_result('ctfindvar_test_varsrcsig.fits') | ||
| 141 | - | ||
| 142 | - ## Copy ctfindvar tool | ||
| 143 | - #cpy_tool = ctfindvar.copy() | 131 | + # Check that saving does not nothing |
| 132 | + ctfindvar['logfile'] = 'ctfindvar_py1.log' | ||
| 133 | + ctfindvar.logFileOpen() | ||
| 134 | + ctfindvar.save() | ||
| 135 | + | ||
| 136 | + # Check result | ||
| 137 | + self._check_result_file('ctfindvar_test_python_srcsig.fits') | ||
| 144 | 138 | ||
| 145 | - ## Check result | ||
| 146 | - #self._check_result('ctfindvar_test_srcsig.fits') | 139 | + # Copy ctfindvar tool |
| 140 | + cpy_tool = ctfindvar | ||
| 147 | 141 | ||
| 148 | - ## Run copy of ctfindvar tool again | ||
| 149 | - #cpy_tool['logfile'] = 'ctfindvar_py2.log' | ||
| 150 | - #cpy_tool['chatter'] = 3 | ||
| 151 | - #cpy_tool['prefix'] = 'ctfindvar_copytool_' | ||
| 152 | - #cpy_tool.logFileOpen() | ||
| 153 | - #cpy_tool.run() | 142 | + # Run copy of ctfindvar tool again |
| 143 | + cpy_tool['logfile'] = 'ctfindvar_py2.log' | ||
| 144 | + cpy_tool['chatter'] = 3 | ||
| 145 | + cpy_tool['prefix'] = 'ctfindvar_test_copytool_' | ||
| 146 | + cpy_tool.logFileOpen() | ||
| 147 | + cpy_tool.run() | ||
| 148 | + cpy_tool.save() | ||
| 154 | 149 | ||
| 155 | - ## Check result | ||
| 156 | - #self._check_result('ctfindvar_copytool_srcsig.fits') | 150 | + # Check result |
| 151 | + self._check_result_file('ctfindvar_test_copytool_srcsig.fits') | ||
| 157 | 152 | ||
| 158 | - ## Check that clearing does not lead to an exception or segfault | ||
| 159 | - #ctfindvar.clear() | 153 | + # Check that clearing does not lead to an exception or segfault |
| 154 | + ctfindvar.clear() | ||
| 160 | 155 | ||
| 161 | # Return | 156 | # Return |
| 162 | return | 157 | return |
| 163 | 158 | ||
| 164 | # Check ctfindvar result | 159 | # Check ctfindvar result |
| 165 | - def _check_result(self, filename): | 160 | + def _check_result_file(self, filename): |
| 166 | """ | 161 | """ |
| 167 | Check content of tool | 162 | Check content of tool |
| 168 | 163 | ||
| @@ -171,9 +166,10 @@ class Test(test): | @@ -171,9 +166,10 @@ class Test(test): | ||
| 171 | tool : `~ctools.ctfindvar` | 166 | tool : `~ctools.ctfindvar` |
| 172 | ctfindvar instance | 167 | ctfindvar instance |
| 173 | """ | 168 | """ |
| 169 | + print "checking if you amazing file is valid" | ||
| 174 | # Read variability file | 170 | # Read variability file |
| 175 | - #fits = gammalib.GFits(filename) | ||
| 176 | - #self.test_value(fits.size(), 3, | ||
| 177 | - # 'Check for 3 rows in srcsig file') | 171 | + fits = gammalib.GFits(filename) |
| 172 | + self.test_value(fits.size(), 3, | ||
| 173 | + 'Check for 3 rows in srcsig file') | ||
| 178 | # Return | 174 | # Return |
| 179 | return | 175 | return |