functions and branching assert statementthe text string msgis optional and is simply included to give more meaningful error message if the test fails if we leave this outand only write assert successwe will see general message stating that the test has failed ( so-called assertion error)but without much information about what actually went wrong some rules should be observed when writing test functionsthe test function must have at least one statement of the type assert successwhere success is boolean variable or expressionwhich is true if the test passed and false otherwise we can include more than one assert statement if we wantbut we always need at least one the test function should take no arguments the function to be tested will typically be called with one or more argumentsbut these should be defined as local variables inside the test function the name of the function should always be test_followed by the name of the function we want to test following this convention is useful because it makes it obvious to anyone reading the code that the function is test functionand it is also used by tools that can automatically run all test functions in given file or directory more about this is discussed below if we follow these rulesand remember the fundamental idea that test function simply compares the returned result with the expected resultwriting test functions does not have to be complicated in particularmany of the functions we write in this course will evaluate some kind of mathematical function and then return either number or list/tuple of numbers for this type of functionthe recipe for test functions is quite rigidand the structure is usually exactly the same as in the simple example above if you are new to programmingit can be confusing to be faced with general task such as "write test function for the python function somefunc( , ),and it is natural to ask questions about what arguments the function should be tested for and how you can know what the expected values are in such cases it is important to remember the overall idea of test functionsand also that these are choices that must be made by the programmer you have to choose set of suitable argumentsthen calculate or otherwise predict by hand what the function should return for these argumentsand write the comparison in the test function test function can include multiple tests we can have multiple assert statements in single test function this can be useful if we want to test function with different arguments for instanceif we write test function for one of the piecewise-defined mathematical functions considered earlier in this it would be natural to test all the separate intervals on which the function is defined the following code illustrates how this can be donefrom math import sinpi def ( )if < <pi