@@ -19,17 +19,20 @@ class CanScriptTest(unittest.TestCase):
1919
2020 @classmethod
2121 def setUpClass (cls ):
22- # clean out the argument list
22+ # clean up the argument list so the call to the main() functions
23+ # in test_does_not_crash() succeeds
2324 sys .argv = sys .argv [:1 ]
2425
26+ #: this is override by the subclasses
2527 __test__ = False
2628
2729 __metaclass__ = ABCMeta
2830
2931 #@unittest.skipUnless(IS_UNIX, "commands may only be available on unix")
3032 def test_do_commands_exist (self ):
3133 """This test calls each scripts once and veifies that the help
32- can be read without any errors.
34+ can be read without any other errors, like the script not being
35+ found.
3336 """
3437 for command in self ._commands ():
3538 try :
@@ -38,6 +41,9 @@ def test_do_commands_exist(self):
3841 self .assertEqual (e .returncode , errno .EINVAL ,
3942 'Calling "{}" failed (exit code was {} and not EINVAL/22):\n {}'
4043 .format (command , e .returncode , e .output ))
44+ else :
45+ # this is also okay
46+ pass
4147
4248 def test_does_not_crash (self ):
4349 # test import
@@ -50,10 +56,15 @@ def test_does_not_crash(self):
5056
5157 @abstractmethod
5258 def _commands (self ):
59+ """Returns an Iterable of commands that should "succeed", meaning they exit
60+ normally (exit code 0) or with the exit code for invalid arguments: EINVAL/22.
61+ """
5362 pass
5463
5564 @abstractmethod
5665 def _import (self ):
66+ """Returns the modue of the script that has a main() function.
67+ """
5768 pass
5869
5970
@@ -65,7 +76,6 @@ def _commands(self):
6576 return (
6677 "can_logger.py --help" ,
6778 "python -m can.logger --help" ,
68- "python -m can.scripts.logger --help"
6979 )
7080
7181 def _import (self ):
@@ -81,7 +91,6 @@ def _commands(self):
8191 return (
8292 "can_player.py --help" ,
8393 "python -m can.player --help" ,
84- "python -m can.scripts.player --help"
8594 )
8695
8796 def _import (self ):
0 commit comments