boB Stepp wrote: >> The hard part is to remember to test whenever a negative index is >> calculated. > > I am assuming that this is relevant to what just came before, the use > of this "or None" check. Is this correct?
No, I mean that you always should test your code against the corner cases. For example a trivial and seemingly harmless function def tail(items, size): return items[-size:] should return an empty list with size=0 (you might get away with undefined behaviour for size<0). If you only have a test class T(unittest.TestCase): def test_tail(self): self.assertEqual(tail("abcde", 2), "de") your coverage tool might be happy, but you are still in for trouble. You need at least self.assertEqual(tail("abcde", 0), "") to be prepared for the 0 == -0 problem. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor