1. Engineering
  2. Computer Science
  3. you are required to implement the following functions though of...

Question: you are required to implement the following functions though of...

Question details

You are required to implement the following functions, though of course you may write other functions to help you complete the task.

The functions work on a list of test cases (I’ll refer to the whole list as a test suite)

Each test case is a tuple of 3 elements

the function to call

the list of parameters to pass to the function

the expected result

The functions:

correct_test_format(test)

Returns True if parameter is a correctly formatted test case.

To check the tuple and list types, use isinstance(obj, type) – try this out in the interpreter

To check if the function argument has the right type, use callable(obj). For example, callable(print) returns True.

correct_suite_format(suite)

Returns True if parameter is a correctly formatted test suite. The parameter must be a list, and each element must be a correctly formatted test case.

run_test(test)

Return True if test passes, False if test is not correctly formatted or does not return expected value

run_suite(suite)

Run list of tests and return a list of [number of tests passed, number of tests failed]

Using python

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution