Skip to content

Commit

Permalink
Fix unit tests for comparing Dictionaries.
Browse files Browse the repository at this point in the history
Replaces `assertContainsSubset` in tests with a functional version that checks equality of asserted values. Previously, only keys were compared.

PiperOrigin-RevId: 571983744
  • Loading branch information
T5 Team authored and t5-copybara committed Oct 9, 2023
1 parent dd1cede commit d909716
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions t5/evaluation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ def assertDictClose(self, a, b, delta=None, places=None):
self.assertAlmostEqual(a[k], b[k], delta=delta, places=places)
except AssertionError as e:
raise AssertionError(str(e) + " for key '%s'" % k)

def assertDictContainsSubset(self, expected_subset, actual_set):
self.assertContainsSubset(expected_subset.keys(), actual_set.keys())
for k in expected_subset:
try:
self.assertEqual(expected_subset[k], actual_set[k])
except AssertionError as e:
raise AssertionError(str(e) + " for key '%s'" % k) from None

0 comments on commit d909716

Please sign in to comment.