Skip to content

Commit c13ff67

Browse files
authored
Update old unittest asserts in tests (#24)
These methods seem to have been renamed at least as of Python 3.12, apart from assertDictContainsSubset which was removed. For that it seems like you need to just need to check the superset is the same as the union with the subset.
1 parent e076972 commit c13ff67

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

tests/server/ui/change_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_change_grouping_criteria(self):
177177
.all()
178178

179179
ret, reg = identify_related_changes(session, ts_db, field_change7, active_indicators)
180-
self.assertNotEquals(self.regression, reg)
180+
self.assertNotEqual(self.regression, reg)
181181
self.assertFalse(ret, "No match with different machine and tests.")
182182
self.regressions.append(reg)
183183
field_change4 = ts_db.FieldChange(self.order1234,

tests/server/ui/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_run_api(self):
174174
"start_time": "2012-04-11T16:28:23",
175175
"id": 1,
176176
"llvm_project_revision": u'154331'}
177-
self.assertDictContainsSubset(expected, j['run'])
177+
self.assertEqual(j['run'], j['run'] | expected)
178178
self.assertEqual(len(j['tests']), 2)
179179
# This should not be a run.
180180
check_json(client, 'api/db_default/v4/nts/runs/100', expected_code=404)

tests/testing/TestingTest.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,18 @@ def test_constructor(self):
336336
self.assertEqual(run_datetime_end_v1.report_version, 1)
337337

338338
# Check failure when info contains __report_version__ key.
339-
self.assertRaisesRegexp(ValueError, '__report_version__.*reserved',
340-
Run, None, None, info)
339+
self.assertRaisesRegex(ValueError, '__report_version__.*reserved',
340+
Run, None, None, info)
341341

342342
# Check missing tag entry in info for format version 1.
343-
self.assertRaisesRegexp(ValueError,
344-
"Missing 'tag' entry in 'info' dictionary",
345-
Run, info={'run_order': 40385})
343+
self.assertRaisesRegex(ValueError,
344+
"Missing 'tag' entry in 'info' dictionary",
345+
Run, info={'run_order': 40385})
346346

347347
# Check missing run_order entry in info for format version 1.
348-
self.assertRaisesRegexp(ValueError,
349-
"Missing 'run_order' entry in 'info'"
350-
" dictionary", Run, info={'tag': 'nts'})
348+
self.assertRaisesRegex(ValueError,
349+
"Missing 'run_order' entry in 'info'"
350+
" dictionary", Run, info={'tag': 'nts'})
351351

352352
# Test empty start and end time in format version 2
353353
self.assertEqual(self.run_float_start_v2.start_time,
@@ -359,10 +359,10 @@ def test_constructor(self):
359359

360360
# Check missing llvm_project_revision entry in info for format
361361
# version 2.
362-
self.assertRaisesRegexp(ValueError,
363-
"Missing 'llvm_project_revision' entry in"
364-
" 'info' dictionary", Run, 0.0, info={},
365-
report_version=2)
362+
self.assertRaisesRegex(ValueError,
363+
"Missing 'llvm_project_revision' entry in"
364+
" 'info' dictionary", Run, 0.0, info={},
365+
report_version=2)
366366

367367
# Check call to check()
368368
self.assertRaises(AssertionError, Run, info=self.info_v2,
@@ -383,8 +383,8 @@ def test_check(self):
383383

384384
# Check no time or info.
385385
self.run_float_start_v2.info = {}
386-
self.assertRaisesRegexp(ValueError, 'No data defined in this Run',
387-
self.run_float_start_v2.check)
386+
self.assertRaisesRegex(ValueError, 'No data defined in this Run',
387+
self.run_float_start_v2.check)
388388

389389
def test_update(self):
390390
# Check update with a supplied end time.

0 commit comments

Comments
 (0)