Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- numbers = [1, 2, 3, 4]
- # Task 1 - Create a new list, calculating the square number (x * x) for each item in the list
- # Expected output:
- # [1, 4, 9, 16]
- # Task 2 - Filter all the even numbers in the list
- # Expected output: [2, 4]
- # Task 3 - Sum all the odd numbers in the list
- # Expected output: 4
- print("Hello!")
- #1
- def foo(lst):
- rs = [x*x for x in lst]
- return rs
- def test_foo_params_success(lst):
- assert isinstance(lst, list) == True
- def test_foo_params_failure(lst):
- assert isinstance(lst, list) == False
- def test_squre(lst):
- rs = foo(lst)
- for index, obj in enumarate(lst):
- assert (obj*obj, rs[index]), True
- test_foo_params_success([1,2,3,4])
- print("Completed!")
- test_foo_params_failure('sd')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement