Skip to content

Commit e836f35

Browse files
committed
Convert unit tests to pytest
1 parent 85364f0 commit e836f35

20 files changed

+592
-723
lines changed

tests/unit/docs/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ def assert_contains_lines_in_order(self, lines, contents=None):
290290
if contents is None:
291291
contents = self.doc_structure.flush_structure().decode('utf-8')
292292
for line in lines:
293-
self.assertIn(line, contents)
293+
assert line in contents
294294
beginning = contents.find(line)
295295
contents = contents[(beginning + len(line)):]
296296

297297
def assert_not_contains_lines(self, lines):
298298
contents = self.doc_structure.flush_structure().decode('utf-8')
299299
for line in lines:
300-
self.assertNotIn(line, contents)
300+
assert line not in contents

tests/unit/docs/test_service.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_document_service_no_resource(self):
9898
os.remove(self.resource_model_file)
9999
service_documenter = ServiceDocumenter('myservice', self.session)
100100
contents = service_documenter.document_service().decode('utf-8')
101-
self.assertNotIn('Service Resource', contents)
101+
assert 'Service Resource' not in contents
102102

103103
def test_document_service_no_paginators(self):
104104
# Delete the resource model so that the resource is not documented
@@ -107,7 +107,7 @@ def test_document_service_no_paginators(self):
107107
os.remove(self.paginator_model_file)
108108
service_documenter = ServiceDocumenter('myservice', self.session)
109109
contents = service_documenter.document_service().decode('utf-8')
110-
self.assertNotIn('Paginators', contents)
110+
assert 'Paginators' not in contents
111111

112112
def test_document_service_no_waiter(self):
113113
# Delete the resource model so that the resource is not documented
@@ -116,7 +116,7 @@ def test_document_service_no_waiter(self):
116116
os.remove(self.waiter_model_file)
117117
service_documenter = ServiceDocumenter('myservice', self.session)
118118
contents = service_documenter.document_service().decode('utf-8')
119-
self.assertNotIn('Waiters', contents)
119+
assert 'Waiters' not in contents
120120

121121
def test_creates_correct_path_to_examples_based_on_service_name(self):
122122
path = os.sep.join([os.path.dirname(boto3.__file__),
@@ -126,9 +126,7 @@ def test_creates_correct_path_to_examples_based_on_service_name(self):
126126
isfile.return_value = False
127127
s = ServiceDocumenter('myservice', self.session)
128128
s.document_service()
129-
self.assertEqual(
130-
isfile.call_args_list[-1],
131-
mock.call(path))
129+
assert isfile.call_args_list[-1] == mock.call(path)
132130

133131
def test_injects_examples_when_found(self):
134132
examples_path = os.sep.join([os.path.dirname(__file__), '..', 'data',
@@ -137,5 +135,5 @@ def test_injects_examples_when_found(self):
137135
'myservice', self.session)
138136
service_documenter.EXAMPLE_PATH = examples_path
139137
contents = service_documenter.document_service().decode('utf-8')
140-
self.assertIn('This is an example', contents)
141-
self.assertNotIn('This is for another service', contents)
138+
assert 'This is an example' in contents
139+
assert 'This is for another service' not in contents

tests/unit/docs/test_utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ class TestGetResourceIgnoreParams(unittest.TestCase):
2020
def test_target_is_single_resource(self):
2121
param = Parameter('InstanceId', 'response')
2222
ignore_params = get_resource_ignore_params([param])
23-
self.assertEqual(ignore_params, ['InstanceId'])
23+
assert ignore_params == ['InstanceId']
2424

2525
def test_target_is_multiple_resources(self):
2626
param = Parameter('InstanceIds[]', 'response')
2727
ignore_params = get_resource_ignore_params([param])
28-
self.assertEqual(ignore_params, ['InstanceIds'])
28+
assert ignore_params == ['InstanceIds']
2929

3030
def test_target_is_element_of_multiple_resources(self):
3131
param = Parameter('InstanceIds[0]', 'response')
3232
ignore_params = get_resource_ignore_params([param])
33-
self.assertEqual(ignore_params, ['InstanceIds'])
33+
assert ignore_params == ['InstanceIds']
3434

3535
def test_target_is_nested_param(self):
3636
param = Parameter('Filters[0].Name', 'response')
3737
ignore_params = get_resource_ignore_params([param])
38-
self.assertEqual(ignore_params, ['Filters'])
38+
assert ignore_params == ['Filters']
3939

4040
param = Parameter('Filters[0].Values[0]', 'response')
4141
ignore_params = get_resource_ignore_params([param])
42-
self.assertEqual(ignore_params, ['Filters'])
42+
assert ignore_params == ['Filters']

0 commit comments

Comments
 (0)