Skip to content
rodrigocam edited this page Mar 22, 2017 · 2 revisions

Introduction

In this project we will use the tool pytest to run all of our tests.

Installation

To install the pytest we are going to use, type at console: sudo apt install python3-pytest

Tests structure

  • Every module (file.py) must have a file named module_name_TEST
  • To make a file test, import the module you are testing. Ex: from (module_name) import *
  • Every test must be named as test_function/method_name

Running pytest

  • To run all tests of a module, type at console: py.test-3 module_name.py
  • To run a specific test, type at console: py.test-3 -k test_name module_name.py
  • To run all tests bellow some path, type at console: py.test-3 somepath
  • To stop after the first failure add the flag -x: py.test-3 -x module_name.py
  • To stop after (N) failures add the flag --maxfail=N: py.test-3 --maxfail=5 module_name.py

Clone this wiki locally