Question
Writing unit tests. Complete the unit tests for testing the evens() and odds() methods. Each unit test should call either odds() or evens(), passing in
Writing unit tests.
Complete the unit tests for testing the evens() and odds() methods. Each unit test should call either odds() or evens(), passing in a known array of values, and then testing the result to ensure only the correct values are in the array. (Hint: Use the self.assertIn() method).
import unittest
def evens(numbers): """Return the even values in numbers""" return [i for i in numbers if (i%2 == 0)]
def odds(numbers): """Return the odd values in numbers""" return [i for i in numbers if (i%2 == 1)]
class TestNumbers(unittest.TestCase): test_nums = [1, 3, 5, 6, 8, 2, 1]
def test_evens(self): # Fill in the unit test.
def test_odds(self): # Fill in the unit test
if __name__ == "__main__": unittest.main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started