I'm writing a set of test cases for users new to Python. One of the problems I've noticed with my tests is that its possible to get false positives. They may have gotten lucky and happened to give every element in the correct order, however they really should be using a structure that is ordered.
So far this is the best solution I could come up with for this solution.
self.assertTrue(isinstance(result, Sequence) or
isinstance(result, GeneratorType) or
callable(getattr(result, '__reversed__', False)))
However, I don't feel confident GeneratorType
is really ordered, or that this test is comprehensive. I feel like there should be a better way to test for this. How do I test that a structure has order?
Aucun commentaire:
Enregistrer un commentaire