diff --git a/ChangeLog b/ChangeLog index 9ffcb50..78996f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Support On/Off analysis in cslightcrv and csphasecrv (#2273) ctselect informs about non-overlapping time interval (#2272) Add tutorial for classical analysis (#2267) + In case of an error, test output is now written into log file (#2264) Fix chatter level handling in ctpsfcube (#2262) Handle On/Off observations by cspull (#2260) Add "statistic" parameter to all likelihood tools and scripts (#2237) diff --git a/NEWS b/NEWS index 8082d7e..d5c0c97 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ ctools release with respect to the precedent release. Configuration ------------- +In case of an error, test output is now written into log file (#2264). + The cscripts::execute() method no longer creates log files, making the cscripts behaviour compliant with that of ctools (#2182). diff --git a/doc/source/admin/release_history/1.5.rst b/doc/source/admin/release_history/1.5.rst index 679d2ef..daa1c49 100644 --- a/doc/source/admin/release_history/1.5.rst +++ b/doc/source/admin/release_history/1.5.rst @@ -39,6 +39,8 @@ Improvements :ref:`ctselect` informs about non-overlapping time interval * [`2267 `_] - Add tutorial for classical analysis +* [`2264 `_] - + In case of an error, test output is now written into log file * [`2260 `_] - Handle On/Off observations by :ref:`cspull` * [`2237 `_] - diff --git a/test/test_cscaldb.py b/test/test_cscaldb.py index a7072a9..0376c9f 100755 --- a/test/test_cscaldb.py +++ b/test/test_cscaldb.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cscaldb script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -68,10 +68,6 @@ class Test(test): # Setup cscaldb command cmd = cscaldb+' logfile="cscaldb_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') diff --git a/test/test_csebins.py b/test/test_csebins.py index b35f8b4..3fc2624 100755 --- a/test/test_csebins.py +++ b/test/test_csebins.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cslightcrv script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -75,10 +75,6 @@ class Test(test): ' outfile="csebins_cmd1.fits"'+ \ ' logfile="csebins_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -94,7 +90,7 @@ class Test(test): ' logfile="csebins_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csebins --help diff --git a/test/test_csfindobs.py b/test/test_csfindobs.py index 1615e27..beb3d53 100755 --- a/test/test_csfindobs.py +++ b/test/test_csfindobs.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csfindobs script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -78,10 +78,6 @@ class Test(test): ' outfile="runlist_cmd1.dat"'+ \ ' logfile="csfindobs_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -97,7 +93,7 @@ class Test(test): ' logfile="csfindobs_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csfindobs --help diff --git a/test/test_csiactcopy.py b/test/test_csiactcopy.py index 37561fc..551ece3 100755 --- a/test/test_csiactcopy.py +++ b/test/test_csiactcopy.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csiactcopy script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -80,10 +80,6 @@ class Test(test): ' outpath="csiactcopy_cmd1"'+ \ ' logfile="csiactcopy_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -98,7 +94,7 @@ class Test(test): ' logfile="csiactcopy_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csiactcopy --help diff --git a/test/test_csiactdata.py b/test/test_csiactdata.py index f1df681..fef044a 100755 --- a/test/test_csiactdata.py +++ b/test/test_csiactdata.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csiactdata script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -75,10 +75,6 @@ class Test(test): cmd = csiactdata+' datapath="'+self._datapath+'"'+ \ ' logfile="csiactdata_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -88,7 +84,7 @@ class Test(test): ' logfile="csiactdata_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csiactdata --help diff --git a/test/test_csiactobs.py b/test/test_csiactobs.py index ed6bc36..0a94066 100755 --- a/test/test_csiactobs.py +++ b/test/test_csiactobs.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csiactobs script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -81,10 +81,6 @@ class Test(test): ' outmodel="csiactobs_bgd_cmd1.xml"'+ \ ' logfile="csiactobs_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -106,7 +102,7 @@ class Test(test): ' chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input datapath when executed from command line') # Setup csiactobs command @@ -120,7 +116,7 @@ class Test(test): ' chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input prodname when executed from command line') # Check csiactobs --help diff --git a/test/test_csinfo.py b/test/test_csinfo.py index 8184ebe..8c80836 100755 --- a/test/test_csinfo.py +++ b/test/test_csinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csinfo script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -18,8 +18,6 @@ # along with this program. If not, see . # # ========================================================================== -#import gammalib -#import cscripts from testing import test @@ -67,10 +65,6 @@ class Test(test): # Setup csinfo command cmd = csinfo - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Execute script without arguments self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -88,9 +82,10 @@ class Test(test): 'Check successful execution with "info" argument from command line') # Execute script with invalid argument - self.test_assert(self._execute(cmd+' not_a_valid_argument') != 0, - 'Check unsuccessful execution with unsupported argument from ' - 'command line') + self.test_assert(self._execute(cmd+' not_a_valid_argument', + success=False) != 0, + 'Check unsuccessful execution with unsupported ' + 'argument from command line') # Return return diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index 4a8c872..17e780c 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cslightcrv script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -82,10 +82,6 @@ class Test(test): ' outfile="lightcurve_cmd1.fits"'+ \ ' logfile="cslightcrv_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -104,7 +100,7 @@ class Test(test): ' logfile="cslightcrv_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cslightcrv --help diff --git a/test/test_csmodelinfo.py b/test/test_csmodelinfo.py index 864f4ef..e07b9b7 100755 --- a/test/test_csmodelinfo.py +++ b/test/test_csmodelinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csmodelinfo script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -18,7 +18,6 @@ # along with this program. If not, see . # # ========================================================================== -#import gammalib import cscripts from testing import test @@ -77,10 +76,6 @@ class Test(test): ' outds9file="csmodelinfo_cmd1.reg"'+ \ ' logfile="csmodelinfo_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -94,7 +89,7 @@ class Test(test): ' logfile="csmodelinfo_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csmodelinfo --help diff --git a/test/test_csmodelmerge.py b/test/test_csmodelmerge.py index 15af7a8..b9f552e 100755 --- a/test/test_csmodelmerge.py +++ b/test/test_csmodelmerge.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csmodelmerge script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -79,10 +79,6 @@ class Test(test): ' outmodel="csmodelmerge_cmd1.xml"'+ \ ' logfile="csmodelmerge_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -96,7 +92,7 @@ class Test(test): ' logfile="csmodelmerge_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csmodelmerge --help diff --git a/test/test_csmodelselect.py b/test/test_csmodelselect.py index 661671e..4444be6 100755 --- a/test/test_csmodelselect.py +++ b/test/test_csmodelselect.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csmodelselect script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -74,10 +74,6 @@ class Test(test): ' outmodel="csmodelselect_cmd1.xml"'+ \ ' logfile="csmodelselect_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -92,7 +88,7 @@ class Test(test): ' logfile="csmodelselect_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csmodelselect --help diff --git a/test/test_csmodelsois.py b/test/test_csmodelsois.py index 944583b..8aa8a14 100755 --- a/test/test_csmodelsois.py +++ b/test/test_csmodelsois.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csmodelsois tool. # -# Copyright (C) 2017 Josh Cardenzana +# Copyright (C) 2017-2018 Josh Cardenzana # # 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 @@ -78,10 +78,6 @@ class Test(test): ' ra=83.63 dec=22.01 proj=CAR'+ \ ' logfile="csmodelsois_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -99,7 +95,7 @@ class Test(test): ' logfile="csmodelsois_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csmodelsois --help diff --git a/test/test_csobs2caldb.py b/test/test_csobs2caldb.py index 9e86336..2f9d873 100755 --- a/test/test_csobs2caldb.py +++ b/test/test_csobs2caldb.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csobs2caldb script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -81,10 +81,6 @@ class Test(test): ' caldb="cta" irf="Cmd1" rootdir="caldb"'+ \ ' logfile="csobs2caldb_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -98,7 +94,7 @@ class Test(test): ' logfile="csobs2caldb_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csobs2caldb --help diff --git a/test/test_csobsdef.py b/test/test_csobsdef.py index 1c45f49..8d18a70 100755 --- a/test/test_csobsdef.py +++ b/test/test_csobsdef.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csobsdef script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -79,10 +79,6 @@ class Test(test): ' emin=0.1 emax=100.0 duration=1800.0 rad=5.0'+ \ ' logfile="csobsdef_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -98,7 +94,7 @@ class Test(test): ' logfile="csobsdef_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csobsdef --help diff --git a/test/test_csobsinfo.py b/test/test_csobsinfo.py index 55990ce..ed8a752 100755 --- a/test/test_csobsinfo.py +++ b/test/test_csobsinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csobsinfo script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -18,7 +18,6 @@ # along with this program. If not, see . # # ========================================================================== -#import gammalib import cscripts from testing import test @@ -77,10 +76,6 @@ class Test(test): ' offset=yes ra=83.63 dec=22.01'+ \ ' logfile="csobsinfo_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -95,7 +90,7 @@ class Test(test): ' logfile="csobsinfo_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csobsinfo --help diff --git a/test/test_csobsselect.py b/test/test_csobsselect.py index 97b7ffc..760d40a 100755 --- a/test/test_csobsselect.py +++ b/test/test_csobsselect.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csobsselect script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -75,10 +75,6 @@ class Test(test): ' dec=22.01 rad=5.0'+ \ ' logfile="csobsselect_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -94,7 +90,7 @@ class Test(test): ' logfile="csobsselect_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csobsselect --help diff --git a/test/test_csphagen.py b/test/test_csphagen.py index df6d099..d9fd5b8 100644 --- a/test/test_csphagen.py +++ b/test/test_csphagen.py @@ -93,10 +93,6 @@ class Test(test): 'outobs="csphagen_cmd1.xml" prefix="csphagen_cmd1" ' + \ 'logfile="csphagen_cmd1.log" chatter=2' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -119,8 +115,8 @@ class Test(test): 'logfile="csphagen_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, - 'Check invalid input file when executed from command line') + self.test_assert(self._execute(cmd, success=False) != 0, + 'Check invalid input file when executed from command line') # Check csphagen --help self._check_help(csphagen) diff --git a/test/test_csphasecrv.py b/test/test_csphasecrv.py index 3635642..df65fc2 100755 --- a/test/test_csphasecrv.py +++ b/test/test_csphasecrv.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csphasecrv script. # -# Copyright (C) 2017 Juergen Knoedlseder +# Copyright (C) 2017-2018 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 @@ -82,10 +82,6 @@ class Test(test): ' outfile="csphasecrv_cmd1.fits"'+ \ ' logfile="csphasecrv_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -103,7 +99,7 @@ class Test(test): ' logfile="csphasecrv_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csphasecrv --help diff --git a/test/test_cspull.py b/test/test_cspull.py index c67ce45..c8dd591 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cspull script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -84,10 +84,6 @@ class Test(test): ' npix=200 binsz=0.05'+ \ ' logfile="cspull_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -106,7 +102,7 @@ class Test(test): ' logfile="cspull_cmd2.log" debug=yes' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cspull --help diff --git a/test/test_csresmap.py b/test/test_csresmap.py index f4b1f30..4b072eb 100755 --- a/test/test_csresmap.py +++ b/test/test_csresmap.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csresmap script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -79,10 +79,6 @@ class Test(test): ' algorithm="SUBDIVSQRT"'+ \ ' logfile="csresmap_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -102,7 +98,7 @@ class Test(test): ' logfile="csresmap_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csresmap --help diff --git a/test/test_csresspec.py b/test/test_csresspec.py index 88f1957..6704db3 100755 --- a/test/test_csresspec.py +++ b/test/test_csresspec.py @@ -81,10 +81,6 @@ class Test(test): ' mask=no algorithm="SUB"' + \ ' logfile="csresspec_cmd1.log" chatter=4' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -102,8 +98,8 @@ class Test(test): ' logfile="csresspec_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, - 'Check invalid input file when executed from command line') + self.test_assert(self._execute(cmd, success=False) != 0, + 'Check invalid input file when executed from command line') # Check csresspec --help self._check_help(csresspec) diff --git a/test/test_csroot2caldb.py b/test/test_csroot2caldb.py index d494b2a..ca7f0dc 100644 --- a/test/test_csroot2caldb.py +++ b/test/test_csroot2caldb.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csroot2caldb script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -19,7 +19,6 @@ # # ========================================================================== import os -#import gammalib import cscripts from testing import test @@ -82,10 +81,6 @@ class Test(test): ' analysis=DESY zenith=20.0 azimuth=0.0'+ \ ' logfile="csroot2caldb_cmd1.log" chatter=2' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') diff --git a/test/test_cssens.py b/test/test_cssens.py index def29bf..cc03fad 100755 --- a/test/test_cssens.py +++ b/test/test_cssens.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cssens script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -79,10 +79,6 @@ class Test(test): ' outfile="cssens_cmd1.dat"'+ \ ' logfile="cssens_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -99,7 +95,7 @@ class Test(test): ' logfile="cssens_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cssens --help diff --git a/test/test_csspec.py b/test/test_csspec.py index 861cc0c..a587ef1 100755 --- a/test/test_csspec.py +++ b/test/test_csspec.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csspec script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -87,10 +87,6 @@ class Test(test): ' outfile="csspec_cmd1.fits"'+ \ ' logfile="csspec_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -108,7 +104,7 @@ class Test(test): ' logfile="csspec_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check csspec --help diff --git a/test/test_cssrcdetect.py b/test/test_cssrcdetect.py index d68e6b4..96ee1e9 100755 --- a/test/test_cssrcdetect.py +++ b/test/test_cssrcdetect.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cssrcdetect script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -78,10 +78,6 @@ class Test(test): ' srcmodel="POINT" bkgmodel="NONE" threshold=10.0'+ \ ' logfile="cssrcdetect_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -97,7 +93,7 @@ class Test(test): ' logfile="cssrcdetect_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cssrcdetect --help diff --git a/test/test_cstsdist.py b/test/test_cstsdist.py index f81a036..dcc3bf4 100755 --- a/test/test_cstsdist.py +++ b/test/test_cstsdist.py @@ -85,10 +85,6 @@ class Test(test): ' outfile="cstsdist_cmd1.dat"'+ \ ' logfile="cstsdist_cmd1.log" chatter=2' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -105,7 +101,7 @@ class Test(test): ' logfile="cstsdist_cmd2.log" chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cstsdist --help diff --git a/test/test_cstsmapmerge.py b/test/test_cstsmapmerge.py index c5b576e..0d41297 100755 --- a/test/test_cstsmapmerge.py +++ b/test/test_cstsmapmerge.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cstsmapmerge script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -79,10 +79,6 @@ class Test(test): ' outmap="cstsmapmerge_cmd1.fits"'+ \ ' logfile="cstsmapmerge_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -96,7 +92,7 @@ class Test(test): ' logfile="cstsmapmerge_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cstsmapmerge --help diff --git a/test/test_cstsmapsplit.py b/test/test_cstsmapsplit.py index 4b26058..5fee17c 100755 --- a/test/test_cstsmapsplit.py +++ b/test/test_cstsmapsplit.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cstsmapsplit script. # -# Copyright (C) 2016-2017 Michael Mayer +# Copyright (C) 2016-2018 Michael Mayer # # 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 @@ -87,10 +87,6 @@ class Test(test): ' outfile="cstsmapsplit_cmd1.dat"'+ \ ' logfile="cstsmapsplit_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -118,7 +114,7 @@ class Test(test): ' logfile="cstsmapsplit_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cstsmapsplit --help diff --git a/test/test_csviscube.py b/test/test_csviscube.py index fbe2516..bfcac45 100755 --- a/test/test_csviscube.py +++ b/test/test_csviscube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csviscube script # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -70,10 +70,6 @@ class Test(test): ' geolat=-24.6272 binsz=10.0 outfile=csviscube_cmd1.fits'+\ ' logfile="csviscube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') diff --git a/test/test_csworkflow.py b/test/test_csworkflow.py index a5aeb9a..64d2151 100755 --- a/test/test_csworkflow.py +++ b/test/test_csworkflow.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the csworkflow script. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -78,10 +78,6 @@ class Test(test): cmd = csworkflow+' inflow="'+self._workflow+'"'+ \ ' logfile="csworkflow_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') diff --git a/test/test_ctbin.py b/test/test_ctbin.py index b14c5b1..55b3823 100755 --- a/test/test_ctbin.py +++ b/test/test_ctbin.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbin tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -77,10 +77,6 @@ class Test(test): ' xref=83.63 yref=22.01 proj="CAR"'+ \ ' logfile="ctbin_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_value(self._execute(cmd), 0, 'Check successful execution from command line') @@ -98,7 +94,7 @@ class Test(test): ' logfile="ctbin_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Setup ctbin command with different ebounds than input diff --git a/test/test_ctbkgcube.py b/test/test_ctbkgcube.py index 0bc383a..55b3de7 100755 --- a/test/test_ctbkgcube.py +++ b/test/test_ctbkgcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbkgcube tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -77,10 +77,6 @@ class Test(test): ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ ' logfile="ctbkgcube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -101,7 +97,7 @@ class Test(test): ' logfile="ctbkgcube_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctbkgcube --help diff --git a/test/test_ctbutterfly.py b/test/test_ctbutterfly.py index f15206c..e3ceb7b 100755 --- a/test/test_ctbutterfly.py +++ b/test/test_ctbutterfly.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbutterfly tool. # -# Copyright (C) 2014-2017 Michal Mayer +# Copyright (C) 2014-2018 Michal Mayer # # 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 @@ -72,10 +72,6 @@ class Test(test): ' emin=0.1 emax=100.0'+ \ ' logfile="ctbutterfly_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -92,7 +88,7 @@ class Test(test): ' logfile="ctbutterfly_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctbutterfly --help diff --git a/test/test_ctcubemask.py b/test/test_ctcubemask.py index db30c41..51d0dad 100755 --- a/test/test_ctcubemask.py +++ b/test/test_ctcubemask.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctcubemask tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -76,10 +76,6 @@ class Test(test): ' emin=0.1 emax=100.0'+ \ ' logfile="ctcubemask_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -96,7 +92,7 @@ class Test(test): ' logfile="ctcubemask_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctcubemask --help diff --git a/test/test_ctedispcube.py b/test/test_ctedispcube.py index 616e576..59bde83 100755 --- a/test/test_ctedispcube.py +++ b/test/test_ctedispcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctedispcube tool. # -# Copyright (C) 2016-2017 Maria Haupt +# Copyright (C) 2016-2018 Maria Haupt # # 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 @@ -76,10 +76,6 @@ class Test(test): ' migramax=2.0 migrabins=10'+ \ ' logfile="ctedispcube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -99,7 +95,7 @@ class Test(test): ' logfile="ctedispcube_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctedispcube --help diff --git a/test/test_cterror.py b/test/test_cterror.py index 1aa3a3b..8e03ba1 100755 --- a/test/test_cterror.py +++ b/test/test_cterror.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cterror tool. # -# Copyright (C) 2015-2017 Florent Forest +# Copyright (C) 2015-2018 Florent Forest # # 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 @@ -71,10 +71,6 @@ class Test(test): ' outmodel="cterror_cmd1.xml"'+ \ ' logfile="cterror_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -90,7 +86,7 @@ class Test(test): ' logfile="cterror_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check cterror --help diff --git a/test/test_ctexpcube.py b/test/test_ctexpcube.py index 31628ba..79544a3 100755 --- a/test/test_ctexpcube.py +++ b/test/test_ctexpcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctexpcube tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -75,10 +75,6 @@ class Test(test): ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ ' logfile="ctexpcube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -97,7 +93,7 @@ class Test(test): ' logfile="ctexpcube_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctexpcube --help diff --git a/test/test_ctlike.py b/test/test_ctlike.py index 682e192..9270532 100755 --- a/test/test_ctlike.py +++ b/test/test_ctlike.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctlike tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -71,10 +71,6 @@ class Test(test): ' outmodel="ctlike_cmd1.xml"'+ \ ' logfile="ctlike_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -90,7 +86,7 @@ class Test(test): ' logfile="ctlike_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctlike --help diff --git a/test/test_ctmapcube.py b/test/test_ctmapcube.py index 879cb1f..b1dc791 100644 --- a/test/test_ctmapcube.py +++ b/test/test_ctmapcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctmapcube tool. # -# Copyright (C) 2016-2017 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -77,10 +77,6 @@ class Test(test): ' xref=83.63 yref=22.01 proj=CAR'+ \ ' logfile="ctmapcube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -97,7 +93,7 @@ class Test(test): ' logfile="ctmapcube_cmd2.log" debug=yes ' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctmapcube --help diff --git a/test/test_ctmodel.py b/test/test_ctmodel.py index 657b6dc..d6f303f 100755 --- a/test/test_ctmodel.py +++ b/test/test_ctmodel.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctmodel tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -77,10 +77,6 @@ class Test(test): ' xref=83.63 yref=22.01'+ \ ' logfile="ctmodel_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -101,7 +97,7 @@ class Test(test): ' logfile="ctmodel_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctmodel --help diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index bbd3e84..f205458 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctobssim tool # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -80,10 +80,6 @@ class Test(test): ' emin=0.1 emax=100.0'+ \ ' logfile="ctobssim_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -103,7 +99,7 @@ class Test(test): ' logfile="ctobssim_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctobssim --help diff --git a/test/test_ctphase.py b/test/test_ctphase.py index d1824c0..b497075 100644 --- a/test/test_ctphase.py +++ b/test/test_ctphase.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctphase tool. # -# Copyright (C) 2017 by Joshua Cardenzana +# Copyright (C) 2017-2018 by Joshua Cardenzana # # 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 @@ -75,10 +75,6 @@ class Test(test): ' inmodel="'+self._model_file+'" srcname="Crab"'+ \ ' logfile="ctphase_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -93,7 +89,7 @@ class Test(test): ' logfile="ctphase_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctphase --help diff --git a/test/test_ctprob.py b/test/test_ctprob.py index 5d7153d..c5a5ef7 100755 --- a/test/test_ctprob.py +++ b/test/test_ctprob.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctprob tool. # -# Copyright (C) 2017 by Leonardo Di Venere +# Copyright (C) 2017-2018 by Leonardo Di Venere # # 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 @@ -92,7 +92,7 @@ class Test(test): ' logfile="ctprob_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctprob --help diff --git a/test/test_ctpsfcube.py b/test/test_ctpsfcube.py index 5cb5cb1..6f6b7de 100755 --- a/test/test_ctpsfcube.py +++ b/test/test_ctpsfcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctpsfcube tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -76,10 +76,6 @@ class Test(test): ' amax=0.3 anumbins=10'+ \ ' logfile="ctpsfcube_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -99,7 +95,7 @@ class Test(test): ' logfile="ctpsfcube_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctpsfcube --help diff --git a/test/test_ctselect.py b/test/test_ctselect.py index 9dcbcd2..383c230 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctselect tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -77,10 +77,6 @@ class Test(test): ' emin=0.2 emax=80.0'+ \ ' logfile="ctselect_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -97,7 +93,7 @@ class Test(test): ' logfile="ctselect_cmd2.log" debug=yes chatter=1' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctselect --help diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index b8f0287..f3d2343 100755 --- a/test/test_ctskymap.py +++ b/test/test_ctskymap.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctskymap tool. # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -73,10 +73,6 @@ class Test(test): ' xref=83.63 yref=22.01 bkgsubtract="NONE"'+ \ ' logfile="ctskymap_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -93,7 +89,7 @@ class Test(test): ' logfile="ctskymap_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Check ctskymap --help diff --git a/test/test_cttsmap.py b/test/test_cttsmap.py index 2e5cb4d..6f664b4 100755 --- a/test/test_cttsmap.py +++ b/test/test_cttsmap.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cttsmap tool # -# Copyright (C) 2014-2017 Juergen Knoedlseder +# Copyright (C) 2014-2018 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 @@ -74,10 +74,6 @@ class Test(test): ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ ' logfile="cttsmap_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -95,7 +91,7 @@ class Test(test): ' logfile="cttsmap_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Setup cttsmap command diff --git a/test/test_ctulimit.py b/test/test_ctulimit.py index 4484477..5a8f180 100755 --- a/test/test_ctulimit.py +++ b/test/test_ctulimit.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctulimit tool. # -# Copyright (C) 2015-2017 Michael Mayer +# Copyright (C) 2015-2018 Michael Mayer # # 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 @@ -18,7 +18,6 @@ # along with this program. If not, see . # # ========================================================================== -#import gammalib import ctools from testing import test @@ -70,10 +69,6 @@ class Test(test): ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' logfile="ctulimit_cmd1.log" chatter=1' - # Check if execution of wrong command fails - self.test_assert(self._execute('command_that_does_not_exist') != 0, - 'Self test of test script') - # Check if execution was successful self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') @@ -85,7 +80,7 @@ class Test(test): ' logfile="ctulimit_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid input file when executed from command line') # Setup ctulimit command @@ -95,7 +90,7 @@ class Test(test): ' logfile="ctulimit_cmd2.log" debug=yes chatter=2' # Check if execution failed - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check invalid source name when executed from command line') # Check ctulimit --help diff --git a/test/testing.py.in b/test/testing.py.in index 6463cfc..b1437e0 100755 --- a/test/testing.py.in +++ b/test/testing.py.in @@ -1,7 +1,7 @@ # ========================================================================== # Python base class for unit tests # -# Copyright (C) 2016 Juergen Knoedlseder +# Copyright (C) 2016-2018 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 @@ -55,6 +55,16 @@ class test(gammalib.GPythonTestSuite): def _script(self, name): """ Set script name + + Parameters + ---------- + name : str + Script name + + Returns + ------- + script : str + Script name including path """ # Set script name dependent on whether the software is installed or # not. If the software is not installed the 'TEST_BUILDDIR' environment @@ -72,6 +82,16 @@ class test(gammalib.GPythonTestSuite): def _tool(self, name): """ Set tool name + + Parameters + ---------- + name : str + Tool name + + Returns + ------- + tool : str + Tool name including path """ # Set tool name dependent on whether the software is installed or # not. If the software is not installed the 'TEST_BUILDDIR' environment @@ -85,16 +105,39 @@ class test(gammalib.GPythonTestSuite): return tool # Execute command and catch any exception - def _execute(self, cmd): + def _execute(self, cmd, success=True): """ Execute command + + Parameters + ---------- + cmd : str + Command string to be executed + success : bool + True if success is expected, False otherwise + + Returns + ------- + rc : int + Return code """ # Execute command, make sure we catch any exception try: - rc = os.system(cmd+' >/dev/null 2>&1') + rc = os.system(cmd+' > ctools_test_output.dmp 2>&1') except: rc = -1 + # If an exception occured then put output on screen + if success and rc != 0 or not success and rc == 0: + print('\n*** Unexpected exception (%d) for command %s:' % (rc, cmd)) + f = open('ctools_test_output.dmp', 'r') + for line in f: + print(line.rstrip('\n')) + f.close() + + # Remove test output + os.remove('ctools_test_output.dmp') + # Return return code return rc @@ -105,7 +148,7 @@ class test(gammalib.GPythonTestSuite): Returns ------- - obs : `~gammalib.gammalib.GObservations` + obs : `~gammalib.GObservations` Observations container """ # Load CTA event list @@ -138,7 +181,7 @@ class test(gammalib.GPythonTestSuite): Returns ------- - obs : `~gammalib.gammalib.GObservations` + obs : `~gammalib.GObservations` Observations container """ # Load CTA event list @@ -168,6 +211,12 @@ class test(gammalib.GPythonTestSuite): # Check def _check_help(self, tool): """ + Check for help text + + Parameters + ---------- + name : str + Tool name """ # Setup tool --help option cmd = tool+' --help' @@ -178,7 +227,7 @@ class test(gammalib.GPythonTestSuite): self.test_value(self._execute(cmd), 0, 'Check successful execution with --help option') else: - self.test_assert(self._execute(cmd) != 0, + self.test_assert(self._execute(cmd, success=False) != 0, 'Check execution failure with --help option') # Return