Recently I have been taking python courses, but still have many problems. I don't know how to write a test case. Here is the question.
Assume that you are repsonsible for testing a sort function, which is being provided by a third party. The implementation should be consistent with the following specification:
== Specification of sort
==
- takes an
Iterable
as a parameter that contains comparable elements - sorts all contained elements without changing the original
Iterable
- elements should be sorted in ascending order (i.e., smallest first)
- always returns a new
List
that contains the sorted elements - If parameter is
None
or non-iterable, returnNone
.
The implementaion can assume that all elements of a provided iterable are comparable data types (e.g., int, float, string). This means that relational operations like '<', '>', etc. are defined. The behavior for data types that are not comparable is not defined and they do not need to be handled.
The test case's structure looks like:
class SortTests(TestCase):
pass
Thanks.
Aucun commentaire:
Enregistrer un commentaire