diff --git a/ChangeLog b/ChangeLog index 1f435ad..006eb2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2017-03-28 +2017-04-04 * Version 1.3.0 released ======================== + Raise exception instead of exiting with return code in Python tests (#1983) Support of map cubes lying outside RoI in ctobssim Support energy boundary FITS file in ctmapcube (#1978) Add csebins script (#1976) diff --git a/NEWS b/NEWS index 0ac2b8c..c2b03e8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.3.0.dev1 -28 March 2017 +4 April 2017 Introduction @@ -11,7 +11,9 @@ ctools release with respect to the precedent release. Configuration ------------- -None +The Python unit tests now raise exceptions instead of exiting with a non- +zero return code so that the user is not thrown out of Python after calling +ctools.test() and cscripts.test() (#1983). Python interface diff --git a/test/test_ctbin.py b/test/test_ctbin.py index b197e4b..6809280 100755 --- a/test/test_ctbin.py +++ b/test/test_ctbin.py @@ -30,7 +30,7 @@ from testing import test class Test(test): """ Test class for ctbin tool - + This test class makes unit tests for the ctbin tool by using it from the command line and from Python. """ @@ -280,7 +280,7 @@ class Test(test): def _check_observation(self, ctbin, nevents, multiplier=1): """ Check content of an observation - + Parameters ---------- ctbin : `~ctools.ctbin` @@ -316,7 +316,7 @@ class Test(test): def _check_cube(self, cube, nevents, multiplier=1): """ Check content of event cube - + Parameters ---------- cube : `~gammalib.GCTAEventCube` diff --git a/test/test_examples.py.in b/test/test_examples.py.in index 0b9e629..7b5e5ee 100755 --- a/test/test_examples.py.in +++ b/test/test_examples.py.in @@ -532,5 +532,6 @@ if __name__ == '__main__': else: rc = 1 - # Exit with return code - sys.exit(rc) + # Raise an exception in case of failure + if not success: + raise RuntimeError('At least one error occured during the test.') diff --git a/test/test_python_cscripts.py b/test/test_python_cscripts.py index 944723a..ac1c055 100755 --- a/test/test_python_cscripts.py +++ b/test/test_python_cscripts.py @@ -184,8 +184,9 @@ def test(installed=False, debug=False): if installed: os.system('rm -rf %s' % (path)) - # Exit with return code - sys.exit(rc) + # Raise an exception in case of failure + if not success: + raise RuntimeError('At least one error occured during the test.') # ======================== # diff --git a/test/test_python_ctools.py b/test/test_python_ctools.py index 37ecbf9..9f546da 100755 --- a/test/test_python_ctools.py +++ b/test/test_python_ctools.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctools package # -# Copyright (C) 2012-2016 Juergen Knoedlseder +# Copyright (C) 2012-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -143,8 +143,9 @@ def test(installed=False): if installed: os.system('rm -rf %s' % (path)) - # Exit with return code - sys.exit(rc) + # Raise an exception in case of failure + if not success: + raise RuntimeError('At least one error occured during the test.') # ======================== #