diff --git a/MyCapytain/resources/texts/local/capitains/cts.py b/MyCapytain/resources/texts/local/capitains/cts.py index 786f6812..ef01fc86 100644 --- a/MyCapytain/resources/texts/local/capitains/cts.py +++ b/MyCapytain/resources/texts/local/capitains/cts.py @@ -659,7 +659,7 @@ def siblingsId(self) -> Tuple[CtsReference, CtsReference]: if start + 1 == len(document_references) or end + 1 == len(document_references): # If the passage is already at the end _next = None - elif end + range_length > len(document_references): + elif end + range_length >= len(document_references): if start == end: _next = document_references[-1] else: diff --git a/tests/resources/texts/local/commonTests.py b/tests/resources/texts/local/commonTests.py index 5932e0f6..78dbb817 100644 --- a/tests/resources/texts/local/commonTests.py +++ b/tests/resources/texts/local/commonTests.py @@ -716,6 +716,10 @@ def test_siblingsId(self, simple): self.assertEqual(("1-4", "9-12"), (str(p), str(n)), "Middle node should have right siblings") p, n = self.FULL_EPIGRAMMATA.getTextualNode(CtsReference("5-10"), simple=simple).siblingsId self.assertEqual(("1-4", "11-14"), (str(p), str(n)), "Middle node should have right siblings") + # This test makes sure that siblingsId functions when end + range_length == len(document_references) + # Previously when this was the case siblingsId would throw an IndexError + p, n = self.FULL_EPIGRAMMATA.getTextualNode(CtsReference("2-8"), simple=simple).siblingsId + self.assertEqual(("1-1", "9-14"), (str(p), str(n)), "Middle node should have right siblings") # NONE ! p, n = self.FULL_EPIGRAMMATA.getTextualNode(CtsReference("1-14"), simple=simple).siblingsId self.assertEqual((None, None), (p, n), "If whole range, nothing !")