pytest testing framework @pytest mark parametrize decorator @pytest mark parametrize('input ,input ,expected'( )( )]def test_calculator_add_operation(calculatorinput input ,expected)calculator set(input calculator add(calculator set(input calculator add(assert calculator total =expected this illustrates setting up parametrised test for the calculator in which two input values are added together and compared with the expected result note that the parameters are named in the decorator and then list of tuples is used to define the values to be used for the parameters in this case the test_ calculator_add_operation will be run two passing in and and then passing in and for the parameters input input and expected respectively testing for exceptions you can write tests that verify that an exception was raised this is useful as testing negative behaviour is as important as testing positive behaviour for examplewe might want to verify that particular exception is raised when we attempt to withdraw money from bank account which will take us over our overdraft limit to verify the presence of an exception in pytest use the with statement and pytest raises this is context manager that will verify on exit that the specified exception was raised it is used as followswith pytest raises(accounts balanceerror)current_account withdraw( ignoring tests in some cases it is useful to write test for functionality that has not yet been implementedthis may be to ensure that the test is not forgotten or because it helps to document what the item under test should do howeverif the test is run then the test suite as whole will fail because the test is running against behaviour that has yet to be written