Commit 735df6597f17e87ce27d81ad7fea159c68fbcab0
1 parent
3814d11a
Use "Exception as e" instead of "Exception, e" to make test scripts compatible with Python 3.
Note that this breaks compatibility with Python < 2.6.
Showing
14 changed files
with
30 additions
and
30 deletions
test/test_ctbin.py
| @@ -83,7 +83,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -83,7 +83,7 @@ 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 Exception, e: | 86 | + except Exception as e: |
| 87 | msg = "Exception occured in ctbin: %s." % (e,) | 87 | msg = "Exception occured in ctbin: %s." % (e,) |
| 88 | self.test_try_failure(msg) | 88 | self.test_try_failure(msg) |
| 89 | 89 | ||
| @@ -92,7 +92,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -92,7 +92,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 92 | try: | 92 | try: |
| 93 | bin.save() | 93 | bin.save() |
| 94 | self.test_try_success() | 94 | self.test_try_success() |
| 95 | - except Exception, e: | 95 | + except Exception as e: |
| 96 | msg = "Exception occured in saving counts cube: %s." % (e,) | 96 | msg = "Exception occured in saving counts cube: %s." % (e,) |
| 97 | self.test_try_failure(msg) | 97 | self.test_try_failure(msg) |
| 98 | 98 |
test/test_ctbkgcube.py
| @@ -91,7 +91,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -91,7 +91,7 @@ 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 Exception, e: | 94 | + except Exception as e: |
| 95 | msg = "Exception occured in ctbkgcube: %s." % (e,) | 95 | msg = "Exception occured in ctbkgcube: %s." % (e,) |
| 96 | self.test_try_failure(msg) | 96 | self.test_try_failure(msg) |
| 97 | 97 | ||
| @@ -100,7 +100,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -100,7 +100,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 100 | try: | 100 | try: |
| 101 | bkgcube.save() | 101 | bkgcube.save() |
| 102 | self.test_try_success() | 102 | self.test_try_success() |
| 103 | - except Exception, e: | 103 | + except Exception as e: |
| 104 | msg = "Exception occured in saving background cube: %s." % (e,) | 104 | msg = "Exception occured in saving background cube: %s." % (e,) |
| 105 | self.test_try_failure(msg) | 105 | self.test_try_failure(msg) |
| 106 | 106 |
test/test_ctbutterfly.py
| @@ -81,7 +81,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -81,7 +81,7 @@ 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 Exception, e: | 84 | + except Exception as e: |
| 85 | msg = "Exception occured in ctbutterfly: %s." % (e,) | 85 | msg = "Exception occured in ctbutterfly: %s." % (e,) |
| 86 | self.test_try_failure(msg) | 86 | self.test_try_failure(msg) |
| 87 | 87 | ||
| @@ -90,7 +90,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -90,7 +90,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 90 | try: | 90 | try: |
| 91 | butterfly.save() | 91 | butterfly.save() |
| 92 | self.test_try_success() | 92 | self.test_try_success() |
| 93 | - except Exception, e: | 93 | + except Exception as e: |
| 94 | msg = "Exception occured in saving butterfly diagram: %s." % (e,) | 94 | msg = "Exception occured in saving butterfly diagram: %s." % (e,) |
| 95 | self.test_try_failure(msg) | 95 | self.test_try_failure(msg) |
| 96 | 96 |
test/test_ctcubemask.py
| @@ -79,7 +79,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -79,7 +79,7 @@ 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 Exception, e: | 82 | + except Exception as e: |
| 83 | msg = "Exception occured in ctcubemask: %s." % (e,) | 83 | msg = "Exception occured in ctcubemask: %s." % (e,) |
| 84 | self.test_try_failure(msg) | 84 | self.test_try_failure(msg) |
| 85 | 85 | ||
| @@ -88,7 +88,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -88,7 +88,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 88 | try: | 88 | try: |
| 89 | mask.save() | 89 | mask.save() |
| 90 | self.test_try_success() | 90 | self.test_try_success() |
| 91 | - except Exception, e: | 91 | + except Exception as e: |
| 92 | msg = "Exception occured in saving counts cube: %s." % (e,) | 92 | msg = "Exception occured in saving counts cube: %s." % (e,) |
| 93 | self.test_try_failure(msg) | 93 | self.test_try_failure(msg) |
| 94 | 94 |
test/test_cterror.py
| @@ -80,7 +80,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -80,7 +80,7 @@ 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 Exception, e: | 83 | + except Exception as e: |
| 84 | msg = "Exception occured in cterror: %s." % (e,) | 84 | msg = "Exception occured in cterror: %s." % (e,) |
| 85 | self.test_try_failure(msg) | 85 | self.test_try_failure(msg) |
| 86 | 86 | ||
| @@ -89,7 +89,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -89,7 +89,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 89 | try: | 89 | try: |
| 90 | error.save() | 90 | error.save() |
| 91 | self.test_try_success() | 91 | self.test_try_success() |
| 92 | - except Exception, e: | 92 | + except Exception as e: |
| 93 | msg = "Exception occured in saving results: %s." % (e,) | 93 | msg = "Exception occured in saving results: %s." % (e,) |
| 94 | self.test_try_failure(msg) | 94 | self.test_try_failure(msg) |
| 95 | 95 |
test/test_ctexpcube.py
| @@ -88,7 +88,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -88,7 +88,7 @@ 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 Exception, e: | 91 | + except Exception as e: |
| 92 | msg = "Exception occured in ctexpcube: %s." % (e,) | 92 | msg = "Exception occured in ctexpcube: %s." % (e,) |
| 93 | self.test_try_failure(msg) | 93 | self.test_try_failure(msg) |
| 94 | 94 | ||
| @@ -97,7 +97,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -97,7 +97,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 97 | try: | 97 | try: |
| 98 | expcube.save() | 98 | expcube.save() |
| 99 | self.test_try_success() | 99 | self.test_try_success() |
| 100 | - except Exception, e: | 100 | + except Exception as e: |
| 101 | msg = "Exception occured in saving exposure cube: %s." % (e,) | 101 | msg = "Exception occured in saving exposure cube: %s." % (e,) |
| 102 | self.test_try_failure(msg) | 102 | self.test_try_failure(msg) |
| 103 | 103 |
test/test_ctlike.py
| @@ -78,7 +78,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -78,7 +78,7 @@ 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 Exception, e: | 81 | + except Exception as e: |
| 82 | msg = "Exception occured in ctlike: %s." % (e,) | 82 | msg = "Exception occured in ctlike: %s." % (e,) |
| 83 | self.test_try_failure(msg) | 83 | self.test_try_failure(msg) |
| 84 | 84 | ||
| @@ -87,7 +87,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -87,7 +87,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 87 | try: | 87 | try: |
| 88 | like.save() | 88 | like.save() |
| 89 | self.test_try_success() | 89 | self.test_try_success() |
| 90 | - except Exception, e: | 90 | + except Exception as e: |
| 91 | msg = "Exception occured in saving results: %s." % (e,) | 91 | msg = "Exception occured in saving results: %s." % (e,) |
| 92 | self.test_try_failure(msg) | 92 | self.test_try_failure(msg) |
| 93 | 93 |
test/test_ctmodel.py
| @@ -96,7 +96,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -96,7 +96,7 @@ 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 Exception, e: | 99 | + except Exception as e: |
| 100 | msg = "Exception occured in ctmodel: %s." % (e,) | 100 | msg = "Exception occured in ctmodel: %s." % (e,) |
| 101 | self.test_try_failure(msg) | 101 | self.test_try_failure(msg) |
| 102 | 102 | ||
| @@ -105,7 +105,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -105,7 +105,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 105 | try: | 105 | try: |
| 106 | model.save() | 106 | model.save() |
| 107 | self.test_try_success() | 107 | self.test_try_success() |
| 108 | - except Exception, e: | 108 | + except Exception as e: |
| 109 | msg = "Exception occured in saving model cube: %s." % (e,) | 109 | msg = "Exception occured in saving model cube: %s." % (e,) |
| 110 | self.test_try_failure(msg) | 110 | self.test_try_failure(msg) |
| 111 | 111 |
test/test_ctobssim.py
| @@ -84,7 +84,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -84,7 +84,7 @@ 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 Exception, e: | 87 | + except Exception as e: |
| 88 | msg = "Exception occured in ctobssim: %s." % (e,) | 88 | msg = "Exception occured in ctobssim: %s." % (e,) |
| 89 | self.test_try_failure(msg) | 89 | self.test_try_failure(msg) |
| 90 | 90 | ||
| @@ -105,7 +105,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -105,7 +105,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 105 | try: | 105 | try: |
| 106 | sim.save() | 106 | sim.save() |
| 107 | self.test_try_success() | 107 | self.test_try_success() |
| 108 | - except Exception, e: | 108 | + except Exception as e: |
| 109 | msg = "Exception occured in saving events: %s." % (e,) | 109 | msg = "Exception occured in saving events: %s." % (e,) |
| 110 | self.test_try_failure(msg) | 110 | self.test_try_failure(msg) |
| 111 | 111 | ||
| @@ -126,7 +126,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -126,7 +126,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 126 | try: | 126 | try: |
| 127 | sim.run() | 127 | sim.run() |
| 128 | self.test_try_success() | 128 | self.test_try_success() |
| 129 | - except Exception, e: | 129 | + except Exception as e: |
| 130 | msg = "Exception occured in ctobssim: %s." % (e,) | 130 | msg = "Exception occured in ctobssim: %s." % (e,) |
| 131 | self.test_try_failure(msg) | 131 | self.test_try_failure(msg) |
| 132 | 132 | ||
| @@ -138,7 +138,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -138,7 +138,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 138 | try: | 138 | try: |
| 139 | sim.save() | 139 | sim.save() |
| 140 | self.test_try_success() | 140 | self.test_try_success() |
| 141 | - except Exception, e: | 141 | + except Exception as e: |
| 142 | msg = "Exception occured in saving events: %s." % (e,) | 142 | msg = "Exception occured in saving events: %s." % (e,) |
| 143 | self.test_try_failure(msg) | 143 | self.test_try_failure(msg) |
| 144 | 144 |
test/test_ctpsfcube.py
| @@ -90,7 +90,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -90,7 +90,7 @@ 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 Exception, e: | 93 | + except Exception as e: |
| 94 | msg = "Exception occured in ctpsfcube: %s." % (e,) | 94 | msg = "Exception occured in ctpsfcube: %s." % (e,) |
| 95 | self.test_try_failure(msg) | 95 | self.test_try_failure(msg) |
| 96 | 96 | ||
| @@ -99,7 +99,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -99,7 +99,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 99 | try: | 99 | try: |
| 100 | psfcube.save() | 100 | psfcube.save() |
| 101 | self.test_try_success() | 101 | self.test_try_success() |
| 102 | - except Exception, e: | 102 | + except Exception as e: |
| 103 | msg = "Exception occured in saving PSF cube: %s." % (e,) | 103 | msg = "Exception occured in saving PSF cube: %s." % (e,) |
| 104 | self.test_try_failure(msg) | 104 | self.test_try_failure(msg) |
| 105 | 105 |
test/test_ctselect.py
| @@ -79,7 +79,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -79,7 +79,7 @@ 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 Exception, e: | 82 | + except Exception as e: |
| 83 | msg = "Exception occured in ctselect: %s." % (e,) | 83 | msg = "Exception occured in ctselect: %s." % (e,) |
| 84 | self.test_try_failure(msg) | 84 | self.test_try_failure(msg) |
| 85 | 85 | ||
| @@ -88,7 +88,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -88,7 +88,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 88 | try: | 88 | try: |
| 89 | select.save() | 89 | select.save() |
| 90 | self.test_try_success() | 90 | self.test_try_success() |
| 91 | - except Exception, e: | 91 | + except Exception as e: |
| 92 | msg = "Exception occured in saving events: %s." % (e,) | 92 | msg = "Exception occured in saving events: %s." % (e,) |
| 93 | self.test_try_failure(msg) | 93 | self.test_try_failure(msg) |
| 94 | 94 |
test/test_ctskymap.py
| @@ -81,7 +81,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -81,7 +81,7 @@ 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 Exception, e: | 84 | + except Exception as e: |
| 85 | msg = "Exception occured in ctskymap: %s." % (e,) | 85 | msg = "Exception occured in ctskymap: %s." % (e,) |
| 86 | self.test_try_failure(msg) | 86 | self.test_try_failure(msg) |
| 87 | 87 | ||
| @@ -90,7 +90,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -90,7 +90,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 90 | try: | 90 | try: |
| 91 | skymap.save() | 91 | skymap.save() |
| 92 | self.test_try_success() | 92 | self.test_try_success() |
| 93 | - except Exception, e: | 93 | + except Exception as e: |
| 94 | msg = "Exception occured in saving sky map: %s." % (e,) | 94 | msg = "Exception occured in saving sky map: %s." % (e,) |
| 95 | self.test_try_failure(msg) | 95 | self.test_try_failure(msg) |
| 96 | 96 |
test/test_cttsmap.py
| @@ -86,7 +86,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -86,7 +86,7 @@ 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 Exception, e: | 89 | + except Exception as e: |
| 90 | msg = "Exception occured in cttsmap: %s." % (e,) | 90 | msg = "Exception occured in cttsmap: %s." % (e,) |
| 91 | self.test_try_failure(msg) | 91 | self.test_try_failure(msg) |
| 92 | 92 | ||
| @@ -95,7 +95,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -95,7 +95,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 95 | try: | 95 | try: |
| 96 | tsmap.save() | 96 | tsmap.save() |
| 97 | self.test_try_success() | 97 | self.test_try_success() |
| 98 | - except Exception, e: | 98 | + except Exception as e: |
| 99 | msg = "Exception occured in saving results: %s." % (e,) | 99 | msg = "Exception occured in saving results: %s." % (e,) |
| 100 | self.test_try_failure(msg) | 100 | self.test_try_failure(msg) |
| 101 | 101 |
test/test_ctulimit.py
| @@ -78,7 +78,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -78,7 +78,7 @@ 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 Exception, e: | 81 | + except Exception as e: |
| 82 | msg = "Exception occured in ctulimit: %s." % (e,) | 82 | msg = "Exception occured in ctulimit: %s." % (e,) |
| 83 | self.test_try_failure(msg) | 83 | self.test_try_failure(msg) |
| 84 | 84 | ||
| @@ -87,7 +87,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -87,7 +87,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 87 | try: | 87 | try: |
| 88 | ulimit.save() | 88 | ulimit.save() |
| 89 | self.test_try_success() | 89 | self.test_try_success() |
| 90 | - except Exception, e: | 90 | + except Exception as e: |
| 91 | msg = "Exception occured in saving results: %s." % (e,) | 91 | msg = "Exception occured in saving results: %s." % (e,) |
| 92 | self.test_try_failure(msg) | 92 | self.test_try_failure(msg) |
| 93 | 93 |