From 133af572072bf7bc92c23a609773c2ea66e483b7 Mon Sep 17 00:00:00 2001 From: freddiewanah Date: Fri, 28 Jul 2023 02:51:28 +1000 Subject: [PATCH] Rewrite mostly useless assert in test_trans.py (#3810) This PR updates an assert statement that checks the bounds of a string-slicing operation. The updated assertion provides more accurate and informative error handling by specifically checking the relative values of the indices and the string length. The original assertion was essentially checking if Python's string slicing was behaving as expected. However, it wasn't providing any guarantees or useful information about the bounds i and j themselves. The updated assertion checks that the indices used for slicing are within the bounds of the string. It will throw an AssertionError if the indices are out of bounds or if i > j, providing a more specific and informative error. --- tests/test_trans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_trans.py b/tests/test_trans.py index dce8a93..784e852 100644 --- a/tests/test_trans.py +++ b/tests/test_trans.py @@ -13,7 +13,7 @@ def test_fexpr_spans() -> None: # a glance than only spans assert len(spans) == len(expected_slices) for (i, j), slice in zip(spans, expected_slices): - assert len(string[i:j]) == j - i + assert 0 <= i <= j <= len(string) assert string[i:j] == slice assert spans == expected_spans -- 2.39.2