Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON HELP TESTING!!! Create and implementing your own function to automate testing: Write a new function, test_reverse, to automate testing of strReverseI and strReverseR. strReverseI

PYTHON HELP TESTING!!!

Create and implementing your own function to automate testing:

Write a new function, test_reverse, to automate testing of strReverseI and strReverseR. strReverseI and strReverseR will be arguments to test_reverse when test_reverse is called - functions are data, too, and in Python functions can be passed as arguments to a function the same as for other data types.

Implement function test_reverse. test_reverse will have one parameter, f, a function (either strReverseR or strReverseI). test_reverse will call f repeatedly, once for each test case, and compare the result returned by the called function to the expected result. test_reverse should report for each test case whether the actual result matches the expected result, e.g.,

Checking(testing123) ... its value 321gnitset is correct!

Checking(a) ... Error: has wrong value b, expected a.

Test cases and expected results should be stored in a tuple of tuples defined in test_reverse. test_reverse should include at least the following tests:

(('', ''),

('a', 'a'),

('xyz', 'zyx'),

('testing123', '321gnitset'),

('hello, world', 'dlrow ,olleh') )

test_reverse should return None.

Write a main function that calls test_reverse two times, once with argument strReverseR, and once with argument strReverseI:

def main(): '''calls string reverse test func 2x'''

test_reverse(p5.strReverseR)

test_reverse(p5.strReverseI)

return None

HERE IS THE STRING REVERSE I AND R CODE I MADE THAT SHOULD WORK (Ignore the comments)

import doctest

def strReverseI(word):

length = len(word) while (length > 0): wordy = word[length-1] length = length - 1 print(wordy, end="") return "" def strReverseR(word):

if (word == ""): return word else: return strReverseR(word[1:]) + word[0]

def main(): print(doctest.testmod()) print(strReverseR("Mason")) print(strReverseI("Mason")) main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions