utils: F-strings are missing the letter "f"

Also adds tests for utils ValueError strings.
This commit is contained in:
mcc 2024-03-11 15:42:13 -04:00 committed by Catherine
parent 5edff532a8
commit 27ca96383e
2 changed files with 4 additions and 4 deletions

View file

@ -16,7 +16,7 @@ class Log2TestCase(unittest.TestCase):
self.assertEqual(ceil_log2(9), 4)
with self.assertRaises(TypeError):
ceil_log2(1.5)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, r"^-1 is negative$"):
ceil_log2(-1)
def test_exact_log2(self):
@ -25,7 +25,7 @@ class Log2TestCase(unittest.TestCase):
self.assertEqual(exact_log2(4), 2)
self.assertEqual(exact_log2(8), 3)
for val in [-1, 0, 3, 5, 6, 7, 9]:
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, (f"^{val} is not a power of 2$")):
exact_log2(val)
with self.assertRaises(TypeError):
exact_log2(1.5)