( true test functions for classes in we introduced test functions as method to verify that our functions were implemented correctlyand the exact same approach can be used to test the implementation of classes inside the test functionwe define parameters for which we know the expected outputand then call our class methods and compare the results with those expected the only additional step involved when testing classes is that we will typically create one or more instances of the class inside the test function and then call their as an exampleconsider test function for the derivative class of the previous section how can we define test case with known output for this classtwo possible methods are(ito compute ( ( hf ( ))/ by hand for some and hor (iiutilize the fact that linear functions are differentiated exactly by our numerical formularegardless of test function based on (iicould look like the followingdef test_derivative()the formula is exact for linear functionsregardless of lambda xa* dfdx derivative(fh= diff abs(dfdx( aassert diff - 'bug in class derivativediff=%sdiff this function follows the standard recipe for test functionswe construct problem with known resultcreate an instance of the classcall the methodand compare the result with the expected result howeversome of the details inside the test function may be worth commenting on firstwe use lambda function to define (xas you may recall from lambda function is simply compact way of defining functionwith lambda xa* being equivalent to def ( )return * the use of the lambda function inside the test function appears straightforward at firstf lambda xa* dfdx derivative(fh= dfdx(