Commit c4bf507e52bfc35d4360afef8a5d4870c93116c2
1 parent
a67e143b
Enhance error messages in case of an exception (now logs also the exception).
Showing
14 changed files
with
103 additions
and
73 deletions
test/test_ctbin.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctbin tool. | 3 | # This scripts performs unit tests for the ctbin tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -83,16 +83,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -83,16 +83,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 83 | try: | 83 | try: |
| 84 | bin.run() | 84 | bin.run() |
| 85 | self.test_try_success() | 85 | self.test_try_success() |
| 86 | - except: | ||
| 87 | - self.test_try_failure("Exception occured in ctbin.") | 86 | + except Exception, e: |
| 87 | + msg = "Exception occured in ctbin: %s." % (e,) | ||
| 88 | + self.test_try_failure(msg) | ||
| 88 | 89 | ||
| 89 | # Save counts cube | 90 | # Save counts cube |
| 90 | self.test_try("Save counts cube") | 91 | self.test_try("Save counts cube") |
| 91 | try: | 92 | try: |
| 92 | bin.save() | 93 | bin.save() |
| 93 | self.test_try_success() | 94 | self.test_try_success() |
| 94 | - except: | ||
| 95 | - self.test_try_failure("Exception occured in saving counts cube.") | 95 | + except Exception, e: |
| 96 | + msg = "Exception occured in saving counts cube: %s." % (e,) | ||
| 97 | + self.test_try_failure(msg) | ||
| 96 | 98 | ||
| 97 | # Return | 99 | # Return |
| 98 | return | 100 | return |
test/test_ctbkgcube.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctbkgcube tool. | 3 | # This scripts performs unit tests for the ctbkgcube tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -91,16 +91,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -91,16 +91,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 91 | try: | 91 | try: |
| 92 | bkgcube.run() | 92 | bkgcube.run() |
| 93 | self.test_try_success() | 93 | self.test_try_success() |
| 94 | - except: | ||
| 95 | - self.test_try_failure("Exception occured in ctbkgcube.") | 94 | + except Exception, e: |
| 95 | + msg = "Exception occured in ctbkgcube: %s." % (e,) | ||
| 96 | + self.test_try_failure(msg) | ||
| 96 | 97 | ||
| 97 | # Save background cube | 98 | # Save background cube |
| 98 | self.test_try("Save background cube") | 99 | self.test_try("Save background cube") |
| 99 | try: | 100 | try: |
| 100 | bkgcube.save() | 101 | bkgcube.save() |
| 101 | self.test_try_success() | 102 | self.test_try_success() |
| 102 | - except: | ||
| 103 | - self.test_try_failure("Exception occured in saving background cube.") | 103 | + except Exception, e: |
| 104 | + msg = "Exception occured in saving background cube: %s." % (e,) | ||
| 105 | + self.test_try_failure(msg) | ||
| 104 | 106 | ||
| 105 | # Return | 107 | # Return |
| 106 | return | 108 | return |
test/test_ctbutterfly.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctbutterfly tool. | 3 | # This scripts performs unit tests for the ctbutterfly tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Michal Mayer | 5 | +# Copyright (C) 2014-2016 Michal Mayer |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 81 | try: | 81 | try: |
| 82 | butterfly.run() | 82 | butterfly.run() |
| 83 | self.test_try_success() | 83 | self.test_try_success() |
| 84 | - except: | ||
| 85 | - self.test_try_failure("Exception occured in butterfly.") | 84 | + except Exception, e: |
| 85 | + msg = "Exception occured in ctbutterfly: %s." % (e,) | ||
| 86 | + self.test_try_failure(msg) | ||
| 86 | 87 | ||
| 87 | # Save results | 88 | # Save results |
| 88 | self.test_try("Save results") | 89 | self.test_try("Save results") |
| 89 | try: | 90 | try: |
| 90 | butterfly.save() | 91 | butterfly.save() |
| 91 | self.test_try_success() | 92 | self.test_try_success() |
| 92 | - except: | ||
| 93 | - self.test_try_failure("Exception occured in saving results.") | 93 | + except Exception, e: |
| 94 | + msg = "Exception occured in saving butterfly diagram: %s." % (e,) | ||
| 95 | + self.test_try_failure(msg) | ||
| 94 | 96 | ||
| 95 | # Return | 97 | # Return |
| 96 | return | 98 | return |
test/test_ctcubemask.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctcubemask tool. | 3 | # This scripts performs unit tests for the ctcubemask tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 79 | try: | 79 | try: |
| 80 | mask.run() | 80 | mask.run() |
| 81 | self.test_try_success() | 81 | self.test_try_success() |
| 82 | - except: | ||
| 83 | - self.test_try_failure("Exception occured in ctcubemask.") | 82 | + except Exception, e: |
| 83 | + msg = "Exception occured in ctcubemask: %s." % (e,) | ||
| 84 | + self.test_try_failure(msg) | ||
| 84 | 85 | ||
| 85 | # Save counts cube | 86 | # Save counts cube |
| 86 | self.test_try("Save counts cube") | 87 | self.test_try("Save counts cube") |
| 87 | try: | 88 | try: |
| 88 | mask.save() | 89 | mask.save() |
| 89 | self.test_try_success() | 90 | self.test_try_success() |
| 90 | - except: | ||
| 91 | - self.test_try_failure("Exception occured in saving counts cube.") | 91 | + except Exception, e: |
| 92 | + msg = "Exception occured in saving counts cube: %s." % (e,) | ||
| 93 | + self.test_try_failure(msg) | ||
| 92 | 94 | ||
| 93 | # Return | 95 | # Return |
| 94 | return | 96 | return |
test/test_cterror.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the cterror tool. | 3 | # This scripts performs unit tests for the cterror tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2015 Florent Forest | 5 | +# Copyright (C) 2015-2016 Florent Forest |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -80,16 +80,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -80,16 +80,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 80 | try: | 80 | try: |
| 81 | error.run() | 81 | error.run() |
| 82 | self.test_try_success() | 82 | self.test_try_success() |
| 83 | - except: | ||
| 84 | - self.test_try_failure("Exception occured in cterror.") | 83 | + except Exception, e: |
| 84 | + msg = "Exception occured in cterror: %s." % (e,) | ||
| 85 | + self.test_try_failure(msg) | ||
| 85 | 86 | ||
| 86 | # Save results | 87 | # Save results |
| 87 | self.test_try("Save results") | 88 | self.test_try("Save results") |
| 88 | try: | 89 | try: |
| 89 | error.save() | 90 | error.save() |
| 90 | self.test_try_success() | 91 | self.test_try_success() |
| 91 | - except: | ||
| 92 | - self.test_try_failure("Exception occured in saving results.") | 92 | + except Exception, e: |
| 93 | + msg = "Exception occured in saving results: %s." % (e,) | ||
| 94 | + self.test_try_failure(msg) | ||
| 93 | 95 | ||
| 94 | # Return | 96 | # Return |
| 95 | return | 97 | return |
test/test_ctexpcube.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctexpcube tool. | 3 | # This scripts performs unit tests for the ctexpcube tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -88,16 +88,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -88,16 +88,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 88 | try: | 88 | try: |
| 89 | expcube.run() | 89 | expcube.run() |
| 90 | self.test_try_success() | 90 | self.test_try_success() |
| 91 | - except: | ||
| 92 | - self.test_try_failure("Exception occured in ctexpcube.") | 91 | + except Exception, e: |
| 92 | + msg = "Exception occured in ctexpcube: %s." % (e,) | ||
| 93 | + self.test_try_failure(msg) | ||
| 93 | 94 | ||
| 94 | # Save exposure cube | 95 | # Save exposure cube |
| 95 | self.test_try("Save exposure cube") | 96 | self.test_try("Save exposure cube") |
| 96 | try: | 97 | try: |
| 97 | expcube.save() | 98 | expcube.save() |
| 98 | self.test_try_success() | 99 | self.test_try_success() |
| 99 | - except: | ||
| 100 | - self.test_try_failure("Exception occured in saving exposure cube.") | 100 | + except Exception, e: |
| 101 | + msg = "Exception occured in saving exposure cube: %s." % (e,) | ||
| 102 | + self.test_try_failure(msg) | ||
| 101 | 103 | ||
| 102 | # Return | 104 | # Return |
| 103 | return | 105 | return |
test/test_ctlike.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctlike tool. | 3 | # This scripts performs unit tests for the ctlike tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 78 | try: | 78 | try: |
| 79 | like.run() | 79 | like.run() |
| 80 | self.test_try_success() | 80 | self.test_try_success() |
| 81 | - except: | ||
| 82 | - self.test_try_failure("Exception occured in ctlike.") | 81 | + except Exception, e: |
| 82 | + msg = "Exception occured in ctlike: %s." % (e,) | ||
| 83 | + self.test_try_failure(msg) | ||
| 83 | 84 | ||
| 84 | # Save results | 85 | # Save results |
| 85 | self.test_try("Save results") | 86 | self.test_try("Save results") |
| 86 | try: | 87 | try: |
| 87 | like.save() | 88 | like.save() |
| 88 | self.test_try_success() | 89 | self.test_try_success() |
| 89 | - except: | ||
| 90 | - self.test_try_failure("Exception occured in saving results.") | 90 | + except Exception, e: |
| 91 | + msg = "Exception occured in saving results: %s." % (e,) | ||
| 92 | + self.test_try_failure(msg) | ||
| 91 | 93 | ||
| 92 | # Return | 94 | # Return |
| 93 | return | 95 | return |
test/test_ctmodel.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctmodel tool. | 3 | # This scripts performs unit tests for the ctmodel tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -96,16 +96,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -96,16 +96,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 96 | try: | 96 | try: |
| 97 | model.run() | 97 | model.run() |
| 98 | self.test_try_success() | 98 | self.test_try_success() |
| 99 | - except: | ||
| 100 | - self.test_try_failure("Exception occured in ctmodel.") | 99 | + except Exception, e: |
| 100 | + msg = "Exception occured in ctmodel: %s." % (e,) | ||
| 101 | + self.test_try_failure(msg) | ||
| 101 | 102 | ||
| 102 | # Save counts cube | 103 | # Save counts cube |
| 103 | self.test_try("Save model cube") | 104 | self.test_try("Save model cube") |
| 104 | try: | 105 | try: |
| 105 | model.save() | 106 | model.save() |
| 106 | self.test_try_success() | 107 | self.test_try_success() |
| 107 | - except: | ||
| 108 | - self.test_try_failure("Exception occured in saving model cube.") | 108 | + except Exception, e: |
| 109 | + msg = "Exception occured in saving model cube: %s." % (e,) | ||
| 110 | + self.test_try_failure(msg) | ||
| 109 | 111 | ||
| 110 | # Return | 112 | # Return |
| 111 | return | 113 | return |
test/test_ctobssim.py
| @@ -84,8 +84,9 @@ class Test(gammalib.GPythonTestSuite): | @@ -84,8 +84,9 @@ class Test(gammalib.GPythonTestSuite): | ||
| 84 | try: | 84 | try: |
| 85 | sim.run() | 85 | sim.run() |
| 86 | self.test_try_success() | 86 | self.test_try_success() |
| 87 | - except: | ||
| 88 | - self.test_try_failure("Exception occured in ctobssim.") | 87 | + except Exception, e: |
| 88 | + msg = "Exception occured in ctobssim: %s." % (e,) | ||
| 89 | + self.test_try_failure(msg) | ||
| 89 | 90 | ||
| 90 | # Retrieve observation and check content | 91 | # Retrieve observation and check content |
| 91 | obs = gammalib.GCTAObservation(sim.obs()[0]) | 92 | obs = gammalib.GCTAObservation(sim.obs()[0]) |
| @@ -104,8 +105,9 @@ class Test(gammalib.GPythonTestSuite): | @@ -104,8 +105,9 @@ class Test(gammalib.GPythonTestSuite): | ||
| 104 | try: | 105 | try: |
| 105 | sim.save() | 106 | sim.save() |
| 106 | self.test_try_success() | 107 | self.test_try_success() |
| 107 | - except: | ||
| 108 | - self.test_try_failure("Exception occured in saving events.") | 108 | + except Exception, e: |
| 109 | + msg = "Exception occured in saving events: %s." % (e,) | ||
| 110 | + self.test_try_failure(msg) | ||
| 109 | 111 | ||
| 110 | # Test ctobssim on observation container | 112 | # Test ctobssim on observation container |
| 111 | def test_container(self): | 113 | def test_container(self): |
| @@ -124,8 +126,9 @@ class Test(gammalib.GPythonTestSuite): | @@ -124,8 +126,9 @@ class Test(gammalib.GPythonTestSuite): | ||
| 124 | try: | 126 | try: |
| 125 | sim.run() | 127 | sim.run() |
| 126 | self.test_try_success() | 128 | self.test_try_success() |
| 127 | - except: | ||
| 128 | - self.test_try_failure("Exception occured in ctobssim.") | 129 | + except Exception, e: |
| 130 | + msg = "Exception occured in ctobssim: %s." % (e,) | ||
| 131 | + self.test_try_failure(msg) | ||
| 129 | 132 | ||
| 130 | # Retrieve observation and check content | 133 | # Retrieve observation and check content |
| 131 | self.test_value(sim.obs().size(), 4, "There are not 4 observations") | 134 | self.test_value(sim.obs().size(), 4, "There are not 4 observations") |
| @@ -135,8 +138,9 @@ class Test(gammalib.GPythonTestSuite): | @@ -135,8 +138,9 @@ class Test(gammalib.GPythonTestSuite): | ||
| 135 | try: | 138 | try: |
| 136 | sim.save() | 139 | sim.save() |
| 137 | self.test_try_success() | 140 | self.test_try_success() |
| 138 | - except: | ||
| 139 | - self.test_try_failure("Exception occured in saving events.") | 141 | + except Exception, e: |
| 142 | + msg = "Exception occured in saving events: %s." % (e,) | ||
| 143 | + self.test_try_failure(msg) | ||
| 140 | 144 | ||
| 141 | # Setup observation container | 145 | # Setup observation container |
| 142 | def set_obs(self, number): | 146 | def set_obs(self, number): |
test/test_ctpsfcube.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctpsfcube tool. | 3 | # This scripts performs unit tests for the ctpsfcube tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -90,16 +90,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -90,16 +90,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 90 | try: | 90 | try: |
| 91 | psfcube.run() | 91 | psfcube.run() |
| 92 | self.test_try_success() | 92 | self.test_try_success() |
| 93 | - except: | ||
| 94 | - self.test_try_failure("Exception occured in ctpsfcube.") | 93 | + except Exception, e: |
| 94 | + msg = "Exception occured in ctpsfcube: %s." % (e,) | ||
| 95 | + self.test_try_failure(msg) | ||
| 95 | 96 | ||
| 96 | # Save PSF cube | 97 | # Save PSF cube |
| 97 | self.test_try("Save PSF cube") | 98 | self.test_try("Save PSF cube") |
| 98 | try: | 99 | try: |
| 99 | psfcube.save() | 100 | psfcube.save() |
| 100 | self.test_try_success() | 101 | self.test_try_success() |
| 101 | - except: | ||
| 102 | - self.test_try_failure("Exception occured in saving PSF cube.") | 102 | + except Exception, e: |
| 103 | + msg = "Exception occured in saving PSF cube: %s." % (e,) | ||
| 104 | + self.test_try_failure(msg) | ||
| 103 | 105 | ||
| 104 | # Return | 106 | # Return |
| 105 | return | 107 | return |
test/test_ctselect.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctselect tool. | 3 | # This scripts performs unit tests for the ctselect tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 79 | try: | 79 | try: |
| 80 | select.run() | 80 | select.run() |
| 81 | self.test_try_success() | 81 | self.test_try_success() |
| 82 | - except: | ||
| 83 | - self.test_try_failure("Exception occured in ctselect.") | 82 | + except Exception, e: |
| 83 | + msg = "Exception occured in ctselect: %s." % (e,) | ||
| 84 | + self.test_try_failure(msg) | ||
| 84 | 85 | ||
| 85 | # Save events | 86 | # Save events |
| 86 | self.test_try("Save events") | 87 | self.test_try("Save events") |
| 87 | try: | 88 | try: |
| 88 | select.save() | 89 | select.save() |
| 89 | self.test_try_success() | 90 | self.test_try_success() |
| 90 | - except: | ||
| 91 | - self.test_try_failure("Exception occured in saving events.") | 91 | + except Exception, e: |
| 92 | + msg = "Exception occured in saving events: %s." % (e,) | ||
| 93 | + self.test_try_failure(msg) | ||
| 92 | 94 | ||
| 93 | # Return | 95 | # Return |
| 94 | return | 96 | return |
test/test_ctskymap.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctskymap tool. | 3 | # This scripts performs unit tests for the ctskymap tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 81 | try: | 81 | try: |
| 82 | skymap.run() | 82 | skymap.run() |
| 83 | self.test_try_success() | 83 | self.test_try_success() |
| 84 | - except: | ||
| 85 | - self.test_try_failure("Exception occured in ctskymap.") | 84 | + except Exception, e: |
| 85 | + msg = "Exception occured in ctskymap: %s." % (e,) | ||
| 86 | + self.test_try_failure(msg) | ||
| 86 | 87 | ||
| 87 | # Save counts cube | 88 | # Save counts cube |
| 88 | self.test_try("Save sky map") | 89 | self.test_try("Save sky map") |
| 89 | try: | 90 | try: |
| 90 | skymap.save() | 91 | skymap.save() |
| 91 | self.test_try_success() | 92 | self.test_try_success() |
| 92 | - except: | ||
| 93 | - self.test_try_failure("Exception occured in saving sky map.") | 93 | + except Exception, e: |
| 94 | + msg = "Exception occured in saving sky map: %s." % (e,) | ||
| 95 | + self.test_try_failure(msg) | ||
| 94 | 96 | ||
| 95 | # Return | 97 | # Return |
| 96 | return | 98 | return |
test/test_cttsmap.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the cttsmap tool. | 3 | # This scripts performs unit tests for the cttsmap tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2014 Juergen Knoedlseder | 5 | +# Copyright (C) 2014-2016 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -86,16 +86,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -86,16 +86,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 86 | try: | 86 | try: |
| 87 | tsmap.run() | 87 | tsmap.run() |
| 88 | self.test_try_success() | 88 | self.test_try_success() |
| 89 | - except: | ||
| 90 | - self.test_try_failure("Exception occured in cttsmap.") | 89 | + except Exception, e: |
| 90 | + msg = "Exception occured in cttsmap: %s." % (e,) | ||
| 91 | + self.test_try_failure(msg) | ||
| 91 | 92 | ||
| 92 | # Save results | 93 | # Save results |
| 93 | self.test_try("Save results") | 94 | self.test_try("Save results") |
| 94 | try: | 95 | try: |
| 95 | tsmap.save() | 96 | tsmap.save() |
| 96 | self.test_try_success() | 97 | self.test_try_success() |
| 97 | - except: | ||
| 98 | - self.test_try_failure("Exception occured in saving results.") | 98 | + except Exception, e: |
| 99 | + msg = "Exception occured in saving results: %s." % (e,) | ||
| 100 | + self.test_try_failure(msg) | ||
| 99 | 101 | ||
| 100 | # Return | 102 | # Return |
| 101 | return | 103 | return |
test/test_ctulimit.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # This scripts performs unit tests for the ctulimit tool. | 3 | # This scripts performs unit tests for the ctulimit tool. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2015 Michael Mayer | 5 | +# Copyright (C) 2015-2016 Michael Mayer |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): | @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): | ||
| 78 | try: | 78 | try: |
| 79 | ulimit.run() | 79 | ulimit.run() |
| 80 | self.test_try_success() | 80 | self.test_try_success() |
| 81 | - except: | ||
| 82 | - self.test_try_failure("Exception occured in ctulimit.") | 81 | + except Exception, e: |
| 82 | + msg = "Exception occured in ctulimit: %s." % (e,) | ||
| 83 | + self.test_try_failure(msg) | ||
| 83 | 84 | ||
| 84 | # Save results | 85 | # Save results |
| 85 | self.test_try("Save results") | 86 | self.test_try("Save results") |
| 86 | try: | 87 | try: |
| 87 | ulimit.save() | 88 | ulimit.save() |
| 88 | self.test_try_success() | 89 | self.test_try_success() |
| 89 | - except: | ||
| 90 | - self.test_try_failure("Exception occured in saving results.") | 90 | + except Exception, e: |
| 91 | + msg = "Exception occured in saving results: %s." % (e,) | ||
| 92 | + self.test_try_failure(msg) | ||
| 91 | 93 | ||
| 92 | # Return | 94 | # Return |
| 93 | return | 95 | return |