I have a time-consuming method with non-predefined number of iterations inside it that I need to test:
def testmethod():
objects = get_objects()
for objects in objects:
# Time-consuming iterations
do_something(object)
One iteration is sufficient to test for me. What is the best practice to test this method with one iteration only?
Perhaps turn your method into
Then in your test you can call it with a custom objs parameter.