Testing your Python programs with pytest by Reuven M. Lerner

Testing your Python programs with pytest

Starts Sep 13, 2020 at 6:00 PM IDT

Make your programs more reliable

If you're using Python for your personal enjoyment, then it doesn't really matter how robust the code is. But if you're using Python in mission-critical applications for your company, then making sure that your code is bulletproof isn't just a good idea — it's pretty much mandatory. And the best way to ensure that your code is ready for prime time is to test it thoroughly.

But testing doesn't just make your code more reliable: It also makes you a more productive developer. You can concentrate on developing new features and fixing old bugs, rather than accidentally introducing new ones. Once you get started testing, it'll be hard for you to stop.

Over the last few years, pytest has emerged as an easy to use, popular way to test Python code. pytest is written in Python, and is designed to be used by Python developers in testing Python code. It uses Python programming idioms and paradigms, giving experienced Python developers a seamless experience and a shallow learning curve.

In this live, 4-hour course, I'll introduce you to pytest — what it is, how it works, and how to use it. There will be numerous exercises and many opportunities for you to ask me questions. And when the class is over, you'll have access to the recording to review and learn from again.

Join me in this live, online course. You'll come away with knowledge that you can put to use immediately. Your software will improve, and so will your career!

Course syllabus

  • Why test?
  • Basic pytest installation
  • Assertions
  • Command-line arguments
  • Exceptions
  • Parametrized tests
  • Fixtures

Who am I?

I'm Reuven Lerner, a Python user since 1993, a self-employed consultant since 1995, and a corporate trainer since 2000. In 2019, I traveled to the US, UK, Europe, Israel, India, and China giving corporate training classes to some of the best-known companies in the Fortune 500.

I love helping people to improve their Python coding skills. That's why I frequently speak at Python conferences and meetups, why I wrote my book Python Workout, why I publish videos on my YouTube channel, and why I publish my "Better developers" newsletter, currently read by about 19,000 developers around the world.

I've been using pytest for several years, and have given versions of this class to my consulting clients. This is the first time I'll be offering the class to individuals online. I hope that you'll join me; I promise that it'll be fun and interesting, as well as practical and useful. Before the class ends, you'll already know how to use pytest to make your code better and to save you time at work. What could be better?

Frequently Asked Questions (FAQs)

When will the class take place?

This is a live class; we'll be using Zoom's Webinar software to broadcast it live from my home office to wherever you live or work. It'll take place on Sunday, September 13th at 6 p.m. in Israel (i.e., 4 p.m. in London and 11 a.m. in New York). 

The class will be four hours long.

The time doesn't work for me. Can I still enroll?

Absolutely! Anyone who enrolls in the class will have access — forever! — to the video recording and any files I create during the class.

How much Python do I need to know in order to take this class?

pytest uses Python paradigms and data structures. So you'll want to be pretty familiar with the basic data types (ints, strings, lists, tuples, and dicts), writing functions, and importing from modules. Familiarity with generator functions will certainly help, but aren't mandatory. And you'll need to know how to use pip in order to install modules from PyPI. But you won't need to know a lot more beyond that.

How much pytest do I need to know in order to take this class?

Nothing. I assume that anyone joining this class knows little or nothing about pytest. We'll build up from zero until we're testing all sorts of interesting things.

What version of Python will we use?

I'll be using Python 3.8, the most recent version when the class happens. You can use 3.7 or 3.8 without any trouble.

And you can use any operating system you want; pytest, like Python itself, works well on all platforms.

Will there be any exercises or labs?

Absolutely! If you've taken one my courses before, then you know that I'm a big believer in learning through doing and practice. There will be numerous exercises throughout the course. 

I should note that exercises in a class like this are a bit different from those in a programming class. The aim isn't to solve a programming problem, but rather to get code tested. The code will generally be simple, in order to emphasize the testing techniques we're using.

For how long will I have access to the recording?


Do you offer any discounts?

Yes, my standard discounts apply:
  • Students
  • Pensioners/seniors/retirees
  • People living outside of the world's 30 richest countries
  • Anyone affected adversely by the coronavirus/covid pandemic
If one or more of these categories applies to you, then please e-mail me at reuven@lerner.co.il, and I'll send you an appropriate coupon code. I want my courses to be available to as many people as possible!

I have other questions.

Please e-mail me at reuven@lerner.co.il! I'm always happy to answer questions.