Skip to content

Commit ea1fb5b

Browse files
authored
Merge pull request #331 from xrmx/miscwarnings
Fix a couple of warnings spotted when running python 2.7 tests
2 parents 307f729 + 5aaef29 commit ea1fb5b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

splunklib/searchcommands/validators.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ def __call__(self, value):
9595
try:
9696
return Code.object(compile(value, 'string', self._mode), six.text_type(value))
9797
except (SyntaxError, TypeError) as error:
98-
if six.PY2:
99-
message = error.message
100-
else:
101-
message = str(error)
98+
message = str(error)
10299

103100
six.raise_from(ValueError(message), error)
104101

tests/searchcommands/test_search_command.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_process_scpv1(self):
140140
result = BytesIO()
141141

142142
self.assertRaises(SystemExit, command.process, argv, ofile=result)
143-
self.assertRegexpMatches(result.getvalue().decode('UTF-8'), expected)
143+
six.assertRegex(self, result.getvalue().decode('UTF-8'), expected)
144144

145145
# TestCommand.process should return configuration settings on Getinfo probe
146146

@@ -307,7 +307,8 @@ def test_process_scpv1(self):
307307
command.process(argv, ifile, ofile=result)
308308
except SystemExit as error:
309309
self.assertNotEqual(error.code, 0)
310-
self.assertRegexpMatches(
310+
six.assertRegex(
311+
self,
311312
result.getvalue().decode('UTF-8'),
312313
r'^error_message=RuntimeError at ".+", line \d+ : Testing\r\n\r\n$')
313314
except BaseException as error:
@@ -331,7 +332,8 @@ def test_process_scpv1(self):
331332
except BaseException as error:
332333
self.fail('Expected no exception, but caught {}: {}'.format(type(error).__name__, error))
333334
else:
334-
self.assertRegexpMatches(
335+
six.assertRegex(
336+
self,
335337
result.getvalue().decode('UTF-8'),
336338
r'^\r\n'
337339
r'('
@@ -715,7 +717,8 @@ def test_process_scpv2(self):
715717
r'logging_configuration=\\\".+\\\" logging_level=\\\"WARNING\\\" record=\\\"f\\\" ' \
716718
r'required_option_1=\\\"value_1\\\" required_option_2=\\\"value_2\\\" show_configuration=\\\"f\\\"\"\]\]\}'
717719

718-
self.assertRegexpMatches(
720+
six.assertRegex(
721+
self,
719722
result.getvalue().decode('utf-8'),
720723
r'^chunked 1.0,2,0\n'
721724
r'\{\}\n'

tests/test_examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_handlers(self):
146146
result = run(
147147
"handlers/handlers_certs.py --ca_file=handlers/cacert.bad.pem",
148148
stderr=PIPE)
149-
self.assertNotEquals(result, 0)
149+
self.assertNotEqual(result, 0)
150150

151151
# The proxy handler example requires that there be a proxy available
152152
# to relay requests, so we spin up a local proxy using the proxy
@@ -167,7 +167,7 @@ def test_handlers(self):
167167
# Run it again without the proxy and it should fail.
168168
result = run(
169169
"handlers/handler_proxy.py --proxy=localhost:80801", stderr=PIPE)
170-
self.assertNotEquals(result, 0)
170+
self.assertNotEqual(result, 0)
171171

172172
def test_index(self):
173173
self.check_commands(

tests/test_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_login_and_store_cookie(self):
194194
self.assertEqual(len(self.service.get_cookies()), 0)
195195
self.service.login()
196196
self.assertIsNotNone(self.service.get_cookies())
197-
self.assertNotEquals(self.service.get_cookies(), {})
197+
self.assertNotEqual(self.service.get_cookies(), {})
198198
self.assertEqual(len(self.service.get_cookies()), 1)
199199

200200
def test_login_with_cookie(self):

0 commit comments

Comments
 (0)