Commit e6e9118c6e0d794f4e1b8196552853c0ada19a54
1 parent
ca719e88
Add path to test_python.py file to system path so that import statements also wo…
…rk for absolute imports that are used as standard in Python 3. Also always exist with sys.exit() so that errors are correctly catched by Jenkins.
Showing
1 changed file
with
4 additions
and
6 deletions
test/test_python.py
| @@ -22,6 +22,7 @@ import gammalib | @@ -22,6 +22,7 @@ import gammalib | ||
| 22 | import ctools | 22 | import ctools |
| 23 | import sys | 23 | import sys |
| 24 | import os | 24 | import os |
| 25 | +sys.path.append(os.path.dirname(os.path.abspath(__file__))) | ||
| 25 | import test_ctobssim | 26 | import test_ctobssim |
| 26 | import test_ctselect | 27 | import test_ctselect |
| 27 | import test_ctbin | 28 | import test_ctbin |
| @@ -142,8 +143,8 @@ def test(installed=False): | @@ -142,8 +143,8 @@ def test(installed=False): | ||
| 142 | else: | 143 | else: |
| 143 | rc = 1 | 144 | rc = 1 |
| 144 | 145 | ||
| 145 | - # Return | ||
| 146 | - return rc | 146 | + # Exit with return code |
| 147 | + sys.exit(rc) | ||
| 147 | 148 | ||
| 148 | 149 | ||
| 149 | # ======================== # | 150 | # ======================== # |
| @@ -154,7 +155,4 @@ if __name__ == '__main__': | @@ -154,7 +155,4 @@ if __name__ == '__main__': | ||
| 154 | Perform unit testing for Python interface. | 155 | Perform unit testing for Python interface. |
| 155 | """ | 156 | """ |
| 156 | # Run tests | 157 | # Run tests |
| 157 | - rc = test() | ||
| 158 | - | ||
| 159 | - # Exit with return code | ||
| 160 | - sys.exit(rc) | 158 | + test() |