@@ -756,31 +756,37 @@ def test_statement_is_immutable():
756756 statement .raw = 'baz'
757757
758758
759- def test_is_valid_command (parser ):
759+ def test_is_valid_command_invalid (parser ):
760760 # Empty command
761761 valid , errmsg = parser .is_valid_command ('' )
762762 assert not valid and 'cannot be an empty string' in errmsg
763763
764764 # Starts with shortcut
765- valid , errmsg = parser .is_valid_command ('!cmd ' )
765+ valid , errmsg = parser .is_valid_command ('!ls ' )
766766 assert not valid and 'cannot start with a shortcut' in errmsg
767767
768768 # Contains whitespace
769- valid , errmsg = parser .is_valid_command (' ' )
769+ valid , errmsg = parser .is_valid_command ('shell ls ' )
770770 assert not valid and 'cannot contain: whitespace, quotes,' in errmsg
771771
772772 # Contains a quote
773- valid , errmsg = parser .is_valid_command ('"cmd ' )
773+ valid , errmsg = parser .is_valid_command ('"shell" ' )
774774 assert not valid and 'cannot contain: whitespace, quotes,' in errmsg
775775
776776 # Contains a redirector
777- valid , errmsg = parser .is_valid_command ('>cmd ' )
777+ valid , errmsg = parser .is_valid_command ('>shell ' )
778778 assert not valid and 'cannot contain: whitespace, quotes,' in errmsg
779779
780780 # Contains a terminator
781- valid , errmsg = parser .is_valid_command (';cmd ' )
781+ valid , errmsg = parser .is_valid_command (';shell ' )
782782 assert not valid and 'cannot contain: whitespace, quotes,' in errmsg
783783
784+ def test_is_valid_command_valid (parser ):
785+ # Empty command
786+ valid , errmsg = parser .is_valid_command ('shell' )
787+ assert valid
788+ assert not errmsg
789+
784790
785791def test_macro_normal_arg_pattern ():
786792 # This pattern matches digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side
0 commit comments