topic: Automated Testing in Python

There are many different test frameworks and test runners that Python allows. The main ones people tend to use are:

  • unittest,
  • and pytest.

These are both great tools with pros and cons. We have chosen to teach pytest for our course. But don’t be scared of different frameworks!

Different testing tools have different ways of achieving similar goals. Make sure you understand why we test, what to test and when to test.

If you end up working on a project that uses unittest instead of pytest then use unittest. Eg: Django projects are traditionally tested using unittest instead of Pytest so there is a bunch of cool Django tooling around that, which is fine.

Read and understand the following:

And here are the pytest docs. The official documentation is a source of the latest and greatest straight-from-the-horses-mouth knowledge.

Videos

Pytest is the nicest python testing framework currently out there, but there aren’t so many videos on it, so here are some videos on unit testing in javascript (but they provide a great explanation of why and how you need to test your code) and unit testing with python’s unittest.

Pytest directory structure

We will expect your project to follow industry-recognised best practices when you submit them to us.

NB! Take a look at this repo. We’ll require that you follow this structure when you submit your work.


RAW CONTENT URL