Skip to content

Commit 99cc6d7

Browse files
Copilotjb3
andcommitted
Fix additional DumpError issues in test files
Co-authored-by: jb3 <[email protected]>
1 parent 67495d2 commit 99cc6d7

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

tests/bot/test_converters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ async def test_isodatetime_converter_for_valid(self):
191191

192192
converter = ISODateTime()
193193

194-
for datetime_string, expected_dt in test_values:
195-
with self.subTest(datetime_string=datetime_string, expected_dt=expected_dt):
194+
for i, (datetime_string, expected_dt) in enumerate(test_values):
195+
with self.subTest(test_case=i, datetime_string=datetime_string):
196196
converted_dt = await converter.convert(self.context, datetime_string)
197197
self.assertEqual(converted_dt, expected_dt)
198198

tests/bot/utils/test_message_cache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ def test_slicing_with_unfilled_cache(self):
177177
for msg in messages:
178178
cache.append(msg)
179179

180-
for slice_ in slices:
181-
with self.subTest(current_loop=(size, slice_)):
180+
for i, slice_ in enumerate(slices):
181+
with self.subTest(size=size, slice_index=i):
182182
self.assertListEqual(cache[slice_], messages[slice_])
183183

184184
def test_slicing_with_overfilled_cache(self):
@@ -199,8 +199,8 @@ def test_slicing_with_overfilled_cache(self):
199199
cache.append(msg)
200200
messages = messages[size // 2:]
201201

202-
for slice_ in slices:
203-
with self.subTest(current_loop=(size, slice_)):
202+
for i, slice_ in enumerate(slices):
203+
with self.subTest(size=size, slice_index=i):
204204
self.assertListEqual(cache[slice_], messages[slice_])
205205

206206
def test_length(self):

tests/bot/utils/test_time.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_humanize_delta_should_normal_usage(self):
3232
(relativedelta(days=2, hours=2), "days", 2, "2 days"),
3333
)
3434

35-
for delta, precision, max_units, expected in test_cases:
36-
with self.subTest(delta=delta, precision=precision, max_units=max_units, expected=expected):
35+
for i, (delta, precision, max_units, expected) in enumerate(test_cases):
36+
with self.subTest(test_case=i, precision=precision, max_units=max_units, expected=expected):
3737
actual = time.humanize_delta(delta, precision=precision, max_units=max_units)
3838
self.assertEqual(actual, expected)
3939

@@ -57,8 +57,8 @@ def test_format_with_duration_none_expiry(self):
5757
(None, "Why hello there!", float("inf"), None),
5858
)
5959

60-
for expiry, date_from, max_units, expected in test_cases:
61-
with self.subTest(expiry=expiry, date_from=date_from, max_units=max_units, expected=expected):
60+
for i, (expiry, date_from, max_units, expected) in enumerate(test_cases):
61+
with self.subTest(test_case=i, expiry=expiry, max_units=max_units, expected=expected):
6262
self.assertEqual(time.format_with_duration(expiry, date_from, max_units), expected)
6363

6464
def test_format_with_duration_custom_units(self):
@@ -70,8 +70,8 @@ def test_format_with_duration_custom_units(self):
7070
"<t:32531918940:f> (6 months, 28 days, 23 hours and 54 minutes)")
7171
)
7272

73-
for expiry, date_from, max_units, expected in test_cases:
74-
with self.subTest(expiry=expiry, date_from=date_from, max_units=max_units, expected=expected):
73+
for i, (expiry, date_from, max_units, expected) in enumerate(test_cases):
74+
with self.subTest(test_case=i, max_units=max_units, expected=expected):
7575
self.assertEqual(time.format_with_duration(expiry, date_from, max_units), expected)
7676

7777
def test_format_with_duration_normal_usage(self):
@@ -94,8 +94,8 @@ def test_format_with_duration_normal_usage(self):
9494
(None, datetime(2019, 11, 23, 23, 49, 5, tzinfo=UTC), 2, None),
9595
)
9696

97-
for expiry, date_from, max_units, expected in test_cases:
98-
with self.subTest(expiry=expiry, date_from=date_from, max_units=max_units, expected=expected):
97+
for i, (expiry, date_from, max_units, expected) in enumerate(test_cases):
98+
with self.subTest(test_case=i, max_units=max_units, expected=expected):
9999
self.assertEqual(time.format_with_duration(expiry, date_from, max_units), expected)
100100

101101
def test_until_expiration_with_duration_none_expiry(self):
@@ -109,8 +109,8 @@ def test_until_expiration_with_duration_custom_units(self):
109109
("3000-11-23T20:09:00Z", "<t:32531918940:R>")
110110
)
111111

112-
for expiry, expected in test_cases:
113-
with self.subTest(expiry=expiry, expected=expected):
112+
for i, (expiry, expected) in enumerate(test_cases):
113+
with self.subTest(test_case=i, expiry=expiry, expected=expected):
114114
self.assertEqual(time.until_expiration(expiry,), expected)
115115

116116
def test_until_expiration_normal_usage(self):
@@ -123,6 +123,6 @@ def test_until_expiration_normal_usage(self):
123123
("3000-11-23T20:09:00Z", "<t:32531918940:R>"),
124124
)
125125

126-
for expiry, expected in test_cases:
127-
with self.subTest(expiry=expiry, expected=expected):
126+
for i, (expiry, expected) in enumerate(test_cases):
127+
with self.subTest(test_case=i, expiry=expiry, expected=expected):
128128
self.assertEqual(time.until_expiration(expiry), expected)

tests/test_helpers.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def test_mocks_allows_access_to_attributes_part_of_spec(self):
153153
(helpers.MockMessage(), "mention_everyone"),
154154
)
155155

156-
for mock, valid_attribute in mocks:
157-
with self.subTest(mock=mock):
156+
for i, (mock, valid_attribute) in enumerate(mocks):
157+
with self.subTest(test_case=i, attribute=valid_attribute):
158158
try:
159159
getattr(mock, valid_attribute)
160160
except AttributeError:
@@ -183,8 +183,8 @@ def test_mocks_rejects_access_to_attributes_not_part_of_spec(self):
183183
helpers.MockMessage(),
184184
)
185185

186-
for mock in mocks:
187-
with self.subTest(mock=mock), self.assertRaises(AttributeError):
186+
for i, mock in enumerate(mocks):
187+
with self.subTest(test_case=i), self.assertRaises(AttributeError):
188188
mock.the_cake_is_a_lie # noqa: B018
189189

190190
def test_mocks_use_mention_when_provided_as_kwarg(self):
@@ -195,8 +195,8 @@ def test_mocks_use_mention_when_provided_as_kwarg(self):
195195
(helpers.MockTextChannel, "channel mention"),
196196
)
197197

198-
for mock_type, mention in test_cases:
199-
with self.subTest(mock_type=mock_type, mention=mention):
198+
for i, (mock_type, mention) in enumerate(test_cases):
199+
with self.subTest(test_case=i, mention=mention):
200200
mock = mock_type(mention=mention)
201201
self.assertEqual(mock.mention, mention)
202202

@@ -276,15 +276,15 @@ class MockScragly(helpers.HashableMixin):
276276

277277
def test_mock_class_with_hashable_mixin_uses_id_for_hashing(self):
278278
"""Test if the MagicMock subclasses that implement the HashableMixin use id for hash."""
279-
for mock in self.hashable_mocks:
280-
with self.subTest(mock_class=mock):
279+
for i, mock in enumerate(self.hashable_mocks):
280+
with self.subTest(test_case=i):
281281
instance = helpers.MockRole(id=100)
282282
self.assertEqual(hash(instance), instance.id)
283283

284284
def test_mock_class_with_hashable_mixin_uses_id_for_equality(self):
285285
"""Test if MagicMocks that implement the HashableMixin use id for equality comparisons."""
286-
for mock_class in self.hashable_mocks:
287-
with self.subTest(mock_class=mock_class):
286+
for i, mock_class in enumerate(self.hashable_mocks):
287+
with self.subTest(test_case=i):
288288
instance_one = mock_class()
289289
instance_two = mock_class()
290290
instance_three = mock_class()
@@ -298,8 +298,8 @@ def test_mock_class_with_hashable_mixin_uses_id_for_equality(self):
298298

299299
def test_mock_class_with_hashable_mixin_uses_id_for_nonequality(self):
300300
"""Test if MagicMocks that implement HashableMixin use id for nonequality comparisons."""
301-
for mock_class in self.hashable_mocks:
302-
with self.subTest(mock_class=mock_class):
301+
for i, mock_class in enumerate(self.hashable_mocks):
302+
with self.subTest(test_case=i):
303303
instance_one = mock_class()
304304
instance_two = mock_class()
305305
instance_three = mock_class()
@@ -336,8 +336,8 @@ def test_spec_propagation_of_mock_subclasses(self):
336336
(helpers.MockReaction, "me"),
337337
)
338338

339-
for mock_type, valid_attribute in test_values:
340-
with self.subTest(mock_type=mock_type, attribute=valid_attribute):
339+
for i, (mock_type, valid_attribute) in enumerate(test_values):
340+
with self.subTest(test_case=i, attribute=valid_attribute):
341341
mock = mock_type()
342342
self.assertTrue(isinstance(mock, mock_type))
343343
attribute = getattr(mock, valid_attribute)

0 commit comments

Comments
 (0)