Skip to content

Commit 4495775

Browse files
committed
pytest.ini and remove deprecation warnings
1 parent 3ef82a0 commit 4495775

File tree

6 files changed

+49
-43
lines changed

6 files changed

+49
-43
lines changed

pytest.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[pytest]
2+
markers =
3+
smoke: essential smoke tests
4+
5+
junit_family =
6+
xunit2

tests/searchcommands/test_builtin_options.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,18 @@ def test_logging_level(self):
145145

146146
# logging_level accepts all logging levels and returns their canonical string values
147147

148-
self.assertEquals(warning, command.logging_level)
148+
self.assertEqual(warning, command.logging_level)
149149

150150
for level in logging._levelNames:
151151
if type(level) is int:
152152
command.logging_level = level
153153
level_name = logging.getLevelName(level)
154-
self.assertEquals(command.logging_level, warning if level_name == notset else level_name)
154+
self.assertEqual(command.logging_level, warning if level_name == notset else level_name)
155155
else:
156156
level_name = logging.getLevelName(logging.getLevelName(level))
157157
for variant in level, level.lower(), level.capitalize():
158158
command.logging_level = variant
159-
self.assertEquals(command.logging_level, warning if level_name == notset else level_name)
159+
self.assertEqual(command.logging_level, warning if level_name == notset else level_name)
160160

161161
# logging_level accepts any numeric value
162162

@@ -203,10 +203,10 @@ def _test_boolean_option(self, option):
203203
for variant in value, value.capitalize(), value.upper():
204204
for s in variant, bytes(variant):
205205
option.fset(command, s)
206-
self.assertEquals(option.fget(command), boolean_values[value])
206+
self.assertEqual(option.fget(command), boolean_values[value])
207207

208208
option.fset(command, None)
209-
self.assertEquals(option.fget(command), None)
209+
self.assertEqual(option.fget(command), None)
210210

211211
for value in 13, b'bytes', 'string', object():
212212
try:

tests/searchcommands/test_internals_v1.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def fix_up(cls, command_class): pass
8989

9090
expected = 'testcommandlineparser required_option="t" unnecessary_option="f" field_1 field_2 field_3'
9191
self.assertEqual(expected, str(command))
92-
self.assertEquals(command.fieldnames, fieldnames)
92+
self.assertEqual(command.fieldnames, fieldnames)
9393

9494
# Command line without any unnecessary options
9595

@@ -104,7 +104,7 @@ def fix_up(cls, command_class): pass
104104

105105
expected = 'testcommandlineparser required_option="t" field_1 field_2 field_3'
106106
self.assertEqual(expected, str(command))
107-
self.assertEquals(command.fieldnames, fieldnames)
107+
self.assertEqual(command.fieldnames, fieldnames)
108108

109109
# Command line with missing required options, with or without fieldnames or unnecessary options
110110

@@ -235,7 +235,7 @@ def test_input_header(self):
235235
with closing(StringIO('\r\n'.encode())) as input_file:
236236
input_header.read(input_file)
237237

238-
self.assertEquals(len(input_header), 0)
238+
self.assertEqual(len(input_header), 0)
239239

240240
# One unnamed single-line item (same as no items)
241241

@@ -244,14 +244,14 @@ def test_input_header(self):
244244
with closing(StringIO('this%20is%20an%20unnamed%20single-line%20item\n\n'.encode())) as input_file:
245245
input_header.read(input_file)
246246

247-
self.assertEquals(len(input_header), 0)
247+
self.assertEqual(len(input_header), 0)
248248

249249
input_header = InputHeader()
250250

251251
with closing(StringIO('this%20is%20an%20unnamed\nmulti-\nline%20item\n\n'.encode())) as input_file:
252252
input_header.read(input_file)
253253

254-
self.assertEquals(len(input_header), 0)
254+
self.assertEqual(len(input_header), 0)
255255

256256
# One named single-line item
257257

@@ -260,16 +260,16 @@ def test_input_header(self):
260260
with closing(StringIO('Foo:this%20is%20a%20single-line%20item\n\n'.encode())) as input_file:
261261
input_header.read(input_file)
262262

263-
self.assertEquals(len(input_header), 1)
264-
self.assertEquals(input_header['Foo'], 'this is a single-line item')
263+
self.assertEqual(len(input_header), 1)
264+
self.assertEqual(input_header['Foo'], 'this is a single-line item')
265265

266266
input_header = InputHeader()
267267

268268
with closing(StringIO('Bar:this is a\nmulti-\nline item\n\n'.encode())) as input_file:
269269
input_header.read(input_file)
270270

271-
self.assertEquals(len(input_header), 1)
272-
self.assertEquals(input_header['Bar'], 'this is a\nmulti-\nline item')
271+
self.assertEqual(len(input_header), 1)
272+
self.assertEqual(input_header['Bar'], 'this is a\nmulti-\nline item')
273273

274274
# The infoPath item (which is the path to a file that we open for reads)
275275

@@ -278,7 +278,7 @@ def test_input_header(self):
278278
with closing(StringIO('infoPath:non-existent.csv\n\n'.encode())) as input_file:
279279
input_header.read(input_file)
280280

281-
self.assertEquals(len(input_header), 1)
281+
self.assertEqual(len(input_header), 1)
282282
self.assertEqual(input_header['infoPath'], 'non-existent.csv')
283283

284284
# Set of named items
@@ -348,7 +348,7 @@ def fix_up(cls, command_class): pass
348348
'warn_message=warning_message\r\n'
349349
'\r\n')
350350

351-
self.assertEquals(output_buffer.getvalue(), expected)
351+
self.assertEqual(output_buffer.getvalue(), expected)
352352
return
353353

354354
_package_path = os.path.dirname(__file__)

tests/test_examples.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ExamplesTestCase(testlib.SDKTestCase):
7070
def check_commands(self, *args):
7171
for arg in args:
7272
result = run(arg)
73-
self.assertEquals(result, 0, '"{0}" run failed with result code {1}'.format(arg, result))
73+
self.assertEqual(result, 0, '"{0}" run failed with result code {1}'.format(arg, result))
7474
self.service.login() # Because a Splunk restart invalidates our session
7575

7676
def setUp(self):
@@ -82,14 +82,14 @@ def setUp(self):
8282
@unittest.skipIf(six.PY3, "Async needs work to support Python 3")
8383
def test_async(self):
8484
result = run("async/async.py sync")
85-
self.assertEquals(result, 0)
85+
self.assertEqual(result, 0)
8686

8787
try:
8888
# Only try running the async version of the test if eventlet
8989
# is present on the system
9090
import eventlet
9191
result = run("async/async.py async")
92-
self.assertEquals(result, 0)
92+
self.assertEqual(result, 0)
9393
except:
9494
pass
9595

@@ -98,7 +98,7 @@ def test_build_dir_exists(self):
9898

9999
def test_binding1(self):
100100
result = run("binding1.py")
101-
self.assertEquals(result, 0)
101+
self.assertEqual(result, 0)
102102

103103
def test_conf(self):
104104
try:
@@ -161,7 +161,7 @@ def test_handlers(self):
161161
# try:
162162
# time.sleep(5) # Wait for proxy to finish initializing
163163
# result = run("handlers/handler_proxy.py --proxy=localhost:8080")
164-
# self.assertEquals(result, 0)
164+
# self.assertEqual(result, 0)
165165
# finally:
166166
# process.kill()
167167

@@ -289,9 +289,9 @@ def test_analytics(self):
289289

290290
# Assert applications
291291
applications = retriever.applications()
292-
self.assertEquals(len(applications), 1)
293-
self.assertEquals(applications[0]["name"], "sdk-test")
294-
self.assertEquals(applications[0]["count"], 2)
292+
self.assertEqual(len(applications), 1)
293+
self.assertEqual(applications[0]["name"], "sdk-test")
294+
self.assertEqual(applications[0]["count"], 2)
295295

296296
# Assert events
297297
events = retriever.events()
@@ -328,9 +328,9 @@ def test_analytics(self):
328328
# Assert event over time
329329
over_time = retriever.events_over_time(
330330
time_range = analytics.output.TimeRange.MONTH)
331-
self.assertEquals(len(over_time), 1)
332-
self.assertEquals(len(over_time["test_event"]), 1)
333-
self.assertEquals(over_time["test_event"][0]["count"], 2)
331+
self.assertEqual(len(over_time), 1)
332+
self.assertEqual(len(over_time["test_event"]), 1)
333+
self.assertEqual(over_time["test_event"][0]["count"], 2)
334334

335335
# Now that we're done, we'll clean the index
336336
index.clean()

tests/test_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_read_from_empty_result_set(self):
3030
job = self.service.jobs.create("search index=_internal_does_not_exist | head 2")
3131
while not job.is_done():
3232
sleep(0.5)
33-
self.assertEquals(0, len(list(results.ResultsReader(io.BufferedReader(job.results())))))
33+
self.assertEqual(0, len(list(results.ResultsReader(io.BufferedReader(job.results())))))
3434

3535
def test_read_normal_results(self):
3636
xml_text = """
@@ -162,7 +162,7 @@ def test_read_raw_field_with_segmentation(self):
162162
def assert_parsed_results_equals(self, xml_text, expected_results):
163163
results_reader = results.ResultsReader(BytesIO(xml_text.encode('utf-8')))
164164
actual_results = [x for x in results_reader]
165-
self.assertEquals(expected_results, actual_results)
165+
self.assertEqual(expected_results, actual_results)
166166

167167
if __name__ == "__main__":
168168
try:

tests/test_service.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def test_capabilities(self):
4141
def test_info(self):
4242
info = self.service.info
4343
keys = ["build", "cpu_arch", "guid", "isFree", "isTrial", "licenseKeys",
44-
"licenseSignature", "licenseState", "master_guid", "mode",
44+
"licenseSignature", "licenseState", "master_guid", "mode",
4545
"os_build", "os_name", "os_version", "serverName", "version"]
46-
for key in keys:
46+
for key in keys:
4747
self.assertTrue(key in list(info.keys()))
4848

4949
def test_info_with_namespace(self):
@@ -141,11 +141,11 @@ def test_splunk_version(self):
141141
for version in [(4,3,3), (5,), (5,0,1)]:
142142
with self.fake_splunk_version(version):
143143
self.assertEqual(version, self.service.splunk_version)
144-
144+
145145
def test_query_without_login_raises_auth_error(self):
146146
service = self._create_unauthenticated_service()
147147
self.assertRaises(AuthenticationError, lambda: service.indexes.list())
148-
148+
149149
# This behavior is needed for backward compatibility for code
150150
# prior to the introduction of AuthenticationError
151151
def test_query_without_login_raises_http_401(self):
@@ -181,11 +181,11 @@ def assertIsNotNone(self, obj, msg=None):
181181

182182
def test_login_and_store_cookie(self):
183183
self.assertIsNotNone(self.service.get_cookies())
184-
self.assertEquals(len(self.service.get_cookies()), 0)
184+
self.assertEqual(len(self.service.get_cookies()), 0)
185185
self.service.login()
186186
self.assertIsNotNone(self.service.get_cookies())
187187
self.assertNotEquals(self.service.get_cookies(), {})
188-
self.assertEquals(len(self.service.get_cookies()), 1)
188+
self.assertEqual(len(self.service.get_cookies()), 1)
189189

190190
def test_login_with_cookie(self):
191191
self.service.login()
@@ -202,10 +202,10 @@ def test_login_with_cookie(self):
202202
def test_login_fails_with_bad_cookie(self):
203203
bad_cookie = {'bad': 'cookie'}
204204
service2 = client.Service()
205-
self.assertEquals(len(service2.get_cookies()), 0)
205+
self.assertEqual(len(service2.get_cookies()), 0)
206206
service2.get_cookies().update(bad_cookie)
207207
service2.login()
208-
self.assertEquals(service2.get_cookies(), {'bad': 'cookie'})
208+
self.assertEqual(service2.get_cookies(), {'bad': 'cookie'})
209209

210210
# Should get an error with a bad cookie
211211
try:
@@ -228,7 +228,7 @@ def test_autologin_with_cookie(self):
228228

229229
def test_login_fails_with_no_cookie(self):
230230
service2 = client.Service()
231-
self.assertEquals(len(service2.get_cookies()), 0)
231+
self.assertEqual(len(service2.get_cookies()), 0)
232232

233233
# Should get an error when no authentication method
234234
try:
@@ -330,25 +330,25 @@ def test_trailing_with_n_args_works(self):
330330
class TestEntityNamespacing(testlib.SDKTestCase):
331331
def test_proper_namespace_with_arguments(self):
332332
entity = self.service.apps['search']
333-
self.assertEquals((None,None,"global"), entity._proper_namespace(sharing="global"))
334-
self.assertEquals((None,"search","app"), entity._proper_namespace(sharing="app", app="search"))
335-
self.assertEquals(
333+
self.assertEqual((None,None,"global"), entity._proper_namespace(sharing="global"))
334+
self.assertEqual((None,"search","app"), entity._proper_namespace(sharing="app", app="search"))
335+
self.assertEqual(
336336
("admin", "search", "user"),
337337
entity._proper_namespace(sharing="user", app="search", owner="admin")
338338
)
339339

340340
def test_proper_namespace_with_entity_namespace(self):
341341
entity = self.service.apps['search']
342342
namespace = (entity.access.owner, entity.access.app, entity.access.sharing)
343-
self.assertEquals(namespace, entity._proper_namespace())
343+
self.assertEqual(namespace, entity._proper_namespace())
344344

345345
def test_proper_namespace_with_service_namespace(self):
346346
entity = client.Entity(self.service, client.PATH_APPS + "search")
347347
del entity._state['access']
348348
namespace = (self.service.namespace.owner,
349349
self.service.namespace.app,
350350
self.service.namespace.sharing)
351-
self.assertEquals(namespace, entity._proper_namespace())
351+
self.assertEqual(namespace, entity._proper_namespace())
352352

353353
if __name__ == "__main__":
354354
try:

0 commit comments

Comments
 (0)