|
|
|
|
|
by shagie
149 days ago
|
|
The python code would be def some_call():
return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def print_evens(nums):
for n in filter(lambda n: n % 2 == 0, nums):
print(n)
def func():
filtered = list(filter(lambda n: n % 2 == 0, some_call()))
print_evens(filtered)
if __name__ == "__main__":
func()
How would you write a failing test that prevents the list from some_call() from having the same filter applied to it twice? |
|
https://docs.python.org/3/library/unittest.mock.html#unittes...
Then you would make the mock filter with patch and test the `func` function
psuedo python code would be