@@ -54,12 +54,18 @@ def test_process(self):
5454 # We support dynamic configuration, not static
5555
5656 expected = \
57- 'error_message=Command search appears to be statically configured and static configuration is unsupported by splunklib.searchcommands. Please ensure that default/commands.conf contains this stanza: [search] | filename = foo.py | supports_getinfo = true | supports_rawargs = true | outputheader = true\r \n ' \
57+ '\r \n ' \
58+ 'ERROR,__mv_ERROR' \
59+ '\r \n ' \
60+ 'Command search appears to be statically configured and static configuration is unsupported by splunklib.searchcommands. Please ensure that default/commands.conf contains this stanza: [search] | filename = foo.py | supports_getinfo = true | supports_rawargs = true | outputheader = true,' \
5861 '\r \n '
5962
6063 command = SearchCommand ()
6164 result = StringIO ()
62- command .process (['foo.py' ], output_file = result )
65+
66+ self .assertRaises (
67+ SystemExit , command .process , ['foo.py' ], output_file = result )
68+
6369 result .reset ()
6470 observed = result .read ()
6571 self .assertEqual (expected , observed )
@@ -88,7 +94,8 @@ def test_process(self):
8894
8995 command = SearchCommand ()
9096 result = StringIO ()
91- command .process (['foo.py' , '__GETINFO__' , 'undefined_option=value' ], output_file = result )
97+
98+ self .assertRaises (SystemExit , command .process , ['foo.py' , '__GETINFO__' , 'undefined_option=value' ], output_file = result )
9299 result .reset ()
93100 observed = result .read ()
94101 self .assertEqual (expected , observed )
@@ -97,8 +104,9 @@ def test_process(self):
97104 # errors, if invoked to execute
98105
99106 expected = \
100- 'error_message=Unrecognized option: undefined_option = value\r \n ' \
101- '\r \n '
107+ '\r \n ' \
108+ 'ERROR,__mv_ERROR\r \n ' \
109+ 'Unrecognized option: undefined_option = value,\r \n '
102110
103111 command = SearchCommand ()
104112 result = StringIO ()
@@ -118,7 +126,9 @@ def test_process(self):
118126 # Command.process should exit on processing exceptions
119127
120128 expected = \
121- ''
129+ '\r \n ' \
130+ 'ERROR,__mv_ERROR\r \n ' \
131+ '\' NoneType\' object is not iterable,\r \n '
122132
123133 command = SearchCommand ()
124134 result = StringIO ()
@@ -175,4 +185,7 @@ def test_process(self):
175185
176186 return
177187
178- _package_directory = os .path .dirname (__file__ )
188+ _package_directory = os .path .dirname (__file__ )
189+
190+ if __name__ == "__main__" :
191+ unittest .main ()
0 commit comments