Discovering and running unit tests with pytest

Now, go to the restful01 folder that contains the file, with the virtual environment activated, and run the following command:


The pytest command and the Django REST framework will perform the following actions:

  1. Create a clean test database name test_drones.
  2. Run all the migrations required for the database.
  3. Discover the tests that have to be executed based on the settings specified in the pytest.ini file.
  4. Run all the methods whose name starts with the test_ prefix in the DroneCategoryTests class and display the results. We declared this class in the file and it matches the pattern specified for the python_files setting in the pytest.ini file.
  5. Drop the test database ...

Get Learn Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.