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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!