From 32c8a9ba6069e8ff73319ac6920fd7d1aa7c9b78 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 11 Aug 2017 00:33:58 +0200 Subject: [PATCH] Reduce code duplications --- test/test_cscaldb.py | 5 ++++- test/test_csebins.py | 29 ++++++++++++++++------------- test/test_csfindobs.py | 5 ++++- test/test_csiactcopy.py | 7 +++++-- test/test_csiactdata.py | 5 ++++- test/test_csiactobs.py | 5 ++++- test/test_cslightcrv.py | 3 +++ test/test_csmodelinfo.py | 5 ++++- test/test_csmodelmerge.py | 5 ++++- test/test_csmodelselect.py | 5 ++++- test/test_csobs2caldb.py | 5 ++++- test/test_csobsdef.py | 3 +++ test/test_csobsinfo.py | 5 ++++- test/test_csobsselect.py | 5 ++++- test/test_csphasecrv.py | 3 +++ test/test_cspull.py | 3 +++ test/test_csresmap.py | 3 +++ test/test_csroot2caldb.py | 5 ++++- test/test_cssens.py | 3 +++ test/test_csspec.py | 5 ++++- test/test_cssrcdetect.py | 5 ++++- test/test_cstsdist.py | 3 +++ test/test_cstsmapmerge.py | 7 +++++-- test/test_cstsmapsplit.py | 5 ++++- test/test_csviscube.py | 5 ++++- test/test_csworkflow.py | 3 +++ test/test_ctbin.py | 15 +++------------ test/test_ctbkgcube.py | 15 +++------------ test/test_ctbutterfly.py | 13 ++----------- test/test_ctcubemask.py | 15 +++------------ test/test_ctedispcube.py | 15 +++------------ test/test_cterror.py | 15 +++------------ test/test_ctexpcube.py | 15 +++------------ test/test_ctlike.py | 15 +++------------ test/test_ctmapcube.py | 13 ++----------- test/test_ctmodel.py | 15 +++------------ test/test_ctobssim.py | 13 ++----------- test/test_ctphase.py | 13 ++----------- test/test_ctprob.py | 13 ++----------- test/test_ctpsfcube.py | 15 +++------------ test/test_ctselect.py | 13 ++----------- test/test_ctskymap.py | 15 +++------------ test/test_cttsmap.py | 15 +++------------ test/test_ctulimit.py | 15 +++------------ test/testing.py.in | 19 +++++++++++++++++++ 45 files changed, 177 insertions(+), 242 deletions(-) diff --git a/test/test_cscaldb.py b/test/test_cscaldb.py index 67d5d82..3f38627 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -76,6 +76,9 @@ class Test(test): self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') + # Check cscaldb --help + self._check_help(cscaldb) + # Return return diff --git a/test/test_csebins.py b/test/test_csebins.py index 743c10d..694cae2 100755 --- a/test/test_csebins.py +++ b/test/test_csebins.py @@ -66,14 +66,14 @@ class Test(test): Test csebins on the command line. """ # Set script name - cslightcrv = self._script('csebins') + csebins = self._script('csebins') - # Setup cslightcrv command - cmd = cslightcrv+' inobs="NONE"'+ \ - ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ - ' emin=0.1 emax=100.0'+ \ - ' outfile="csebins_cmd1.fits"'+ \ - ' logfile="csebins_cmd1.log" chatter=1' + # Setup csebins command + cmd = csebins+' inobs="NONE"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ + ' emin=0.1 emax=100.0'+ \ + ' 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, @@ -86,17 +86,20 @@ class Test(test): # Check energy boundaries self._check_ebounds('csebins_cmd1.fits', 33) - # Setup cslightcrv command - cmd = cslightcrv+' inobs="NONE"'+ \ - ' caldb="Database_that_does_not_exist" irf="'+self._irf+'"'+ \ - ' emin=0.1 emax=100.0'+ \ - ' outfile="csebins_cmd2.fits"'+ \ - ' logfile="csebins_cmd2.log" chatter=1' + # Setup csebins command + cmd = csebins+' inobs="NONE"'+ \ + ' caldb="Database_that_does_not_exist" irf="'+self._irf+'"'+ \ + ' emin=0.1 emax=100.0'+ \ + ' outfile="csebins_cmd2.fits"'+ \ + ' logfile="csebins_cmd2.log" chatter=1' # Check if execution failed self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csebins --help + self._check_help(csebins) + # Return return diff --git a/test/test_csfindobs.py b/test/test_csfindobs.py index d686a14..b596738 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -100,6 +100,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csfindobs --help + self._check_help(csfindobs) + # Return return diff --git a/test/test_csiactcopy.py b/test/test_csiactcopy.py index ab6bd69..ccd6c52 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -101,6 +101,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csiactcopy --help + self._check_help(csiactcopy) + # Return return @@ -289,4 +292,4 @@ class Test(test): self.test_value(n_obs, n_expected, 'Check for number of observations') # Return - return \ No newline at end of file + return diff --git a/test/test_csiactdata.py b/test/test_csiactdata.py index 44f8755..7c16a06 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -91,6 +91,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csiactdata --help + self._check_help(csiactdata) + # Return return diff --git a/test/test_csiactobs.py b/test/test_csiactobs.py index 2a99389..452a25c 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -121,6 +121,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input prodname when executed from command line') + # Check csiactobs --help + self._check_help(csiactobs) + # Return return diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index 6e93d25..c8bd1c9 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -101,6 +101,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cslightcrv --help + self._check_help(cslightcrv) + # Return return diff --git a/test/test_csmodelinfo.py b/test/test_csmodelinfo.py index 4038364..65d9eb2 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -97,6 +97,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csmodelinfo --help + self._check_help(csmodelinfo) + # Return return diff --git a/test/test_csmodelmerge.py b/test/test_csmodelmerge.py index 4def7bb..8ab5dbc 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -99,6 +99,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csmodelmerge --help + self._check_help(csmodelmerge) + # Return return diff --git a/test/test_csmodelselect.py b/test/test_csmodelselect.py index 2888214..4985567 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -96,6 +96,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csmodelselect --help + self._check_help(csmodelselect) + # Return return diff --git a/test/test_csobs2caldb.py b/test/test_csobs2caldb.py index 9904a96..d204dd5 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -101,6 +101,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csobs2caldb --help + self._check_help(csobs2caldb) + # Return return diff --git a/test/test_csobsdef.py b/test/test_csobsdef.py index a06ffde..89b0422 100755 --- a/test/test_csobsdef.py +++ b/test/test_csobsdef.py @@ -101,6 +101,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csobsdef --help + self._check_help(csobsdef) + # Return return diff --git a/test/test_csobsinfo.py b/test/test_csobsinfo.py index 6819201..53d1a6d 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -98,6 +98,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csobsinfo --help + self._check_help(csobsinfo) + # Return return diff --git a/test/test_csobsselect.py b/test/test_csobsselect.py index 0cb47f7..96d89d4 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -98,6 +98,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csobsselect --help + self._check_help(csobsselect) + # Return return diff --git a/test/test_csphasecrv.py b/test/test_csphasecrv.py index 50f9b9d..f41c87e 100755 --- a/test/test_csphasecrv.py +++ b/test/test_csphasecrv.py @@ -104,6 +104,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csphasecrv --help + self._check_help(csphasecrv) + # Return return diff --git a/test/test_cspull.py b/test/test_cspull.py index 14c91cf..63d033c 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -108,6 +108,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cspull --help + self._check_help(cspull) + # Return return diff --git a/test/test_csresmap.py b/test/test_csresmap.py index 4f6e93b..6ab139d 100755 --- a/test/test_csresmap.py +++ b/test/test_csresmap.py @@ -105,6 +105,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csresmap --help + self._check_help(csresmap) + # Return return diff --git a/test/test_csroot2caldb.py b/test/test_csroot2caldb.py index 28bccf6..06828c1 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -90,6 +90,9 @@ class Test(test): self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') + # Check csroot2caldb --help + self._check_help(csroot2caldb) + # Return return diff --git a/test/test_cssens.py b/test/test_cssens.py index bdd09db..df53f5a 100755 --- a/test/test_cssens.py +++ b/test/test_cssens.py @@ -99,6 +99,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cssens --help + self._check_help(cssens) + # Return return diff --git a/test/test_csspec.py b/test/test_csspec.py index ec77818..28f93a3 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -108,6 +108,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check csspec --help + self._check_help(csspec) + # Return return diff --git a/test/test_cssrcdetect.py b/test/test_cssrcdetect.py index 02e1461..7dec8cd 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -101,6 +101,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cssrcdetect --help + self._check_help(cssrcdetect) + # Return return diff --git a/test/test_cstsdist.py b/test/test_cstsdist.py index e776369..ecf74ac 100755 --- a/test/test_cstsdist.py +++ b/test/test_cstsdist.py @@ -103,6 +103,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cstsdist --help + self._check_help(cstsdist) + # Return return diff --git a/test/test_cstsmapmerge.py b/test/test_cstsmapmerge.py index 2b8d94c..d16abef 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -98,7 +98,10 @@ class Test(test): # Check if execution failed self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - + + # Check cstsmapmerge --help + self._check_help(cstsmapmerge) + # Return return diff --git a/test/test_cstsmapsplit.py b/test/test_cstsmapsplit.py index ee0ffaa..05038a7 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 Michael Mayer +# Copyright (C) 2016-2017 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 @@ -121,6 +121,9 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') + # Check cstsmapsplit --help + self._check_help(cstsmapsplit) + # Return return diff --git a/test/test_csviscube.py b/test/test_csviscube.py index 421f2fa..55cf397 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 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -78,6 +78,9 @@ class Test(test): self.test_assert(self._execute(cmd) == 0, 'Check successful execution from command line') + # Check csviscube --help + self._check_help(csviscube) + # Return return diff --git a/test/test_csworkflow.py b/test/test_csworkflow.py index 9b2d877..eeab642 100755 --- a/test/test_csworkflow.py +++ b/test/test_csworkflow.py @@ -89,6 +89,9 @@ class Test(test): # Check fit result self._check_fit_result('wf_crab_results.xml') + # Check csworkflow --help + self._check_help(csworkflow) + # Return return diff --git a/test/test_ctbin.py b/test/test_ctbin.py index 6809280..b064e64 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -117,17 +117,8 @@ class Test(test): evt = gammalib.GCTAEventCube('cntmap_cmd3.fits') self._check_cube(evt, 890) - # Setup ctbin --help option - cmd = ctbin+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctbin --help + self._check_help(ctbin) # Return return diff --git a/test/test_ctbkgcube.py b/test/test_ctbkgcube.py index b12cb76..ee59a33 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -104,17 +104,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctbkgcube --help option - cmd = ctbkgcube+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctbkgcube --help + self._check_help(ctbkgcube) # Return return diff --git a/test/test_ctbutterfly.py b/test/test_ctbutterfly.py index 30f9116..107c2d2 100755 --- a/test/test_ctbutterfly.py +++ b/test/test_ctbutterfly.py @@ -96,17 +96,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctbutterfly --help option - cmd = ctbutterfly+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctbutterfly --help + self._check_help(ctbutterfly) # Return return diff --git a/test/test_ctcubemask.py b/test/test_ctcubemask.py index 149f800..e8ed33e 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -99,17 +99,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctcubemask --help option - cmd = ctcubemask+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctcubemask --help + self._check_help(ctcubemask) # Return return diff --git a/test/test_ctedispcube.py b/test/test_ctedispcube.py index 05a8889..acb4af9 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 Maria Haupt +# Copyright (C) 2016-2017 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 @@ -102,17 +102,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctedispcube --help option - cmd = ctedispcube+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctedispcube --help + self._check_help(ctedispcube) # Return return diff --git a/test/test_cterror.py b/test/test_cterror.py index 3490595..8860dce 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-2016 Florent Forest +# Copyright (C) 2015-2017 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 @@ -94,17 +94,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup cterror --help option - cmd = cterror+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check cterror --help + self._check_help(cterror) # Return return diff --git a/test/test_ctexpcube.py b/test/test_ctexpcube.py index 9931c3f..0a9d432 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -100,17 +100,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctexpcube --help option - cmd = ctexpcube+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctexpcube --help + self._check_help(ctexpcube) # Return return diff --git a/test/test_ctlike.py b/test/test_ctlike.py index f010031..5dd4620 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -94,17 +94,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctlike --help option - cmd = ctlike+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctlike --help + self._check_help(ctlike) # Return return diff --git a/test/test_ctmapcube.py b/test/test_ctmapcube.py index f804c0e..48a7c57 100644 --- a/test/test_ctmapcube.py +++ b/test/test_ctmapcube.py @@ -100,17 +100,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctmapcube --help option - cmd = ctmapcube+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctmapcube --help + self._check_help(ctmapcube) # Return return diff --git a/test/test_ctmodel.py b/test/test_ctmodel.py index e58def8..eb64f2d 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -104,17 +104,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctmodel --help option - cmd = ctmodel+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctmodel --help + self._check_help(ctmodel) # Return return diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index 0c5d3be..881e227 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -106,17 +106,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctobssim --help option - cmd = ctobssim+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctobssim --help + self._check_help(ctobssim) # Return return diff --git a/test/test_ctphase.py b/test/test_ctphase.py index e4764e2..66c1538 100644 --- a/test/test_ctphase.py +++ b/test/test_ctphase.py @@ -96,17 +96,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctphase --help option - cmd = ctphase+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctphase --help + self._check_help(ctphase) # Return return diff --git a/test/test_ctprob.py b/test/test_ctprob.py index dd8d9aa..0f3eebf 100755 --- a/test/test_ctprob.py +++ b/test/test_ctprob.py @@ -95,17 +95,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctprob --help option - cmd = ctprob+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctprob --help + self._check_help(ctprob) # Return return diff --git a/test/test_ctpsfcube.py b/test/test_ctpsfcube.py index 534fe38..dc4a3d0 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -102,17 +102,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctpsfcube --help option - cmd = ctpsfcube+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctpsfcube --help + self._check_help(ctpsfcube) # Return return diff --git a/test/test_ctselect.py b/test/test_ctselect.py index e8f9bf6..74ee2a8 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -100,17 +100,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctselect --help option - cmd = ctselect+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctselect --help + self._check_help(ctselect) # Return return diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index 38db35a..54be18c 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -96,17 +96,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctskymap --help option - cmd = ctskymap+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctskymap --help + self._check_help(ctskymap) # Return return diff --git a/test/test_cttsmap.py b/test/test_cttsmap.py index cf4d1bd..4a33842 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-2016 Juergen Knoedlseder +# Copyright (C) 2014-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -115,17 +115,8 @@ class Test(test): # Check result file self._check_result_file('cttsmap_cmd3.fits') - # Setup cttsmap --help option - cmd = cttsmap+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check cttsmap --help + self._check_help(cttsmap) # Return return diff --git a/test/test_ctulimit.py b/test/test_ctulimit.py index e9ccbe9..32ccdf0 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-2016 Michael Mayer +# Copyright (C) 2015-2017 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 @@ -92,17 +92,8 @@ class Test(test): self.test_assert(self._execute(cmd) != 0, 'Check invalid input file when executed from command line') - # Setup ctulimit --help option - cmd = ctulimit+' --help' - - # Check if execution was successful in case that the CTOOLS - # environment variable was set or failed otherwise - if 'CTOOLS' in os.environ: - self.test_value(self._execute(cmd), 0, - 'Check successful execution with --help option') - else: - self.test_assert(self._execute(cmd) != 0, - 'Check execution failure with --help option') + # Check ctulimit --help + self._check_help(ctulimit) # Return return diff --git a/test/testing.py.in b/test/testing.py.in index e1815e5..6463cfc 100755 --- a/test/testing.py.in +++ b/test/testing.py.in @@ -164,3 +164,22 @@ class test(gammalib.GPythonTestSuite): # Return observation container return obs + + # Check + def _check_help(self, tool): + """ + """ + # Setup tool --help option + cmd = tool+' --help' + + # Check if execution was successful in case that the CTOOLS + # environment variable was set or failed otherwise + if 'CTOOLS' in os.environ: + self.test_value(self._execute(cmd), 0, + 'Check successful execution with --help option') + else: + self.test_assert(self._execute(cmd) != 0, + 'Check execution failure with --help option') + + # Return + return -- libgit2 0.21.4