Commit 166d83b728d0dd2142e799f7e557418d60ce6b6f

Authored by Jürgen Knödlseder
1 parent 4218166f

Clean up code (#1983)

ChangeLog
1   -2017-03-28
  1 +2017-04-04
2 2  
3 3 * Version 1.3.0 released
4 4 ========================
5 5  
  6 + Raise exception instead of exiting with return code in Python tests (#1983)
6 7 Support of map cubes lying outside RoI in ctobssim
7 8 Support energy boundary FITS file in ctmapcube (#1978)
8 9 Add csebins script (#1976)
... ...
1 1 New Features and Important Changes in ctools 1.3.0.dev1
2 2  
3   -28 March 2017
  3 +4 April 2017
4 4  
5 5  
6 6 Introduction
... ... @@ -11,7 +11,9 @@ ctools release with respect to the precedent release.
11 11  
12 12 Configuration
13 13 -------------
14   -None
  14 +The Python unit tests now raise exceptions instead of exiting with a non-
  15 +zero return code so that the user is not thrown out of Python after calling
  16 +ctools.test() and cscripts.test() (#1983).
15 17  
16 18  
17 19 Python interface
... ...
test/test_ctbin.py
... ... @@ -30,7 +30,7 @@ from testing import test
30 30 class Test(test):
31 31 """
32 32 Test class for ctbin tool
33   -
  33 +
34 34 This test class makes unit tests for the ctbin tool by using it from
35 35 the command line and from Python.
36 36 """
... ... @@ -87,8 +87,7 @@ class Test(test):
87 87  
88 88 # Load counts cube and check content.
89 89 evt = gammalib.GCTAEventCube('cntmap_cmd1.fits')
90   - #JKself._check_cube(evt, 5542)
91   - self._check_cube(evt, 5543)
  90 + self._check_cube(evt, 5542)
92 91  
93 92 # Setup ctbin command
94 93 cmd = ctbin+' inobs="events_that_do_not_exist.fits"'+ \
... ... @@ -281,7 +280,7 @@ class Test(test):
281 280 def _check_observation(self, ctbin, nevents, multiplier=1):
282 281 """
283 282 Check content of an observation
284   -
  283 +
285 284 Parameters
286 285 ----------
287 286 ctbin : `~ctools.ctbin`
... ... @@ -317,7 +316,7 @@ class Test(test):
317 316 def _check_cube(self, cube, nevents, multiplier=1):
318 317 """
319 318 Check content of event cube
320   -
  319 +
321 320 Parameters
322 321 ----------
323 322 cube : `~gammalib.GCTAEventCube`
... ...
test/test_examples.py.in
... ... @@ -487,8 +487,7 @@ class Test(gammalib.GPythonTestSuite):
487 487 args = '-p example_show_pointings.eps %s/obs_unbinned.xml' % self._datadir
488 488  
489 489 # Execute script
490   - #JKself._execute_python('show_pointings', args=args)
491   - self._execute_python('show_pointing', args=args)
  490 + self._execute_python('show_pointings', args=args)
492 491  
493 492 # Return
494 493 return
... ... @@ -533,7 +532,6 @@ if __name__ == '__main__':
533 532 else:
534 533 rc = 1
535 534  
536   - # Exit with return code
  535 + # Raise an exception in case of failure
537 536 if not success:
538 537 raise RuntimeError('At least one error occured during the test.')
539   - #sys.exit(rc)
... ...
test/test_python_cscripts.py
... ... @@ -184,10 +184,9 @@ def test(installed=False, debug=False):
184 184 if installed:
185 185 os.system('rm -rf %s' % (path))
186 186  
187   - # Exit with return code
  187 + # Raise an exception in case of failure
188 188 if not success:
189 189 raise RuntimeError('At least one error occured during the test.')
190   - #sys.exit(rc)
191 190  
192 191  
193 192 # ======================== #
... ...
test/test_python_ctools.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # This scripts performs unit tests for the ctools package
4 4 #
5   -# Copyright (C) 2012-2016 Juergen Knoedlseder
  5 +# Copyright (C) 2012-2017 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -143,10 +143,9 @@ def test(installed=False):
143 143 if installed:
144 144 os.system('rm -rf %s' % (path))
145 145  
146   - # Throw an exception in case of failure
  146 + # Raise an exception in case of failure
147 147 if not success:
148 148 raise RuntimeError('At least one error occured during the test.')
149   - #sys.exit(rc)
150 149  
151 150  
152 151 # ======================== #
... ...