3.1. Exercises

Using Pytest Questions

More Questions on Using Pytest

Making a Test Function

Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.

Let’s do the first step in testing the function find_force() with pytest by converting the tests provided for into an appropriate function.

Tasks:

  • Take these unit tests we wrote and compile them together in a function to test the function find_force().
  • Don’t forget to give it a name compliant with pytest’s needs.
Hint 1
  • Are you naming it something starting with test?
  • Are you remembering these functions do not need to return anything?
  • These functions do not take any arguments.
Fully worked solution: