Python Classroom Series – 31/Jul/2021


  • Pytest not only makes it simple to write tests, it has many command line options that increase productivity, such as running the last failed tests or running a specific group of tests by name
  • Customization is important and pytest goes a step further by defining a very powerful plugin system. Plugins can change several aspects of the test run, from how tests are executed to providing new fixtures and capabilities to make it eas to test many types of application frameworks.
  • There are plugins that execute the tests in random order each time to ensure tests are not changing global state that might effect other tests.
  • There are number of external plugins Refer Here

Writing and running tests

  • Using pytest all you need to do to start writing tests is to create a new file named test_*.py and write test functions that start with test
  • Refer Here for the changes
  • We can start executing the tests just by executing the pytest command Preview
  • Refer Here for seperate folder added for tests
  • Lets try to run a specific test case test_iseven_negative() in
pytest .\tests\ -v
  • To see which tests are there without running them use –collect-only
pytest --collect-only


  • Exercise: Create some basic tests for the inventory application.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin