GithubHelp home page GithubHelp logo

pytest-okken-2022's Introduction

Original source code

The link to the original source code is given on the official book's side

https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/

Install using PyPI

Create a virtual environment, activate it on POSIX systems, and install pytest

$ python3 -m venv my_venv
$ source my_venv/bin/activate
(my_venv) $ pip install pytest

or using virtualenv

$ python3 -m pip install virtualenv
$ python3 -m virtualenv my_venv
$ source my_venv/bin/activate
(my_venv) $ pip install pytest

Deactivate the venv

(my_venv) $ deactivate

Create a virtual environment, activate it on Windows systems, and install pytest

C:\> python -m venv my_venv
C:\> my_venv\Scripts\activate.bat
(my_venv) C:\> pip install pytest

Activate in PowerShell

C:>my_venv\Scripts\Activate.ps1

Run pytest

Run a test modul:

$ pytest 01-introduction/test_01-1--passing.py

Run a test modul with the --verbose or -v flag:

$ pytest -v 01-introduction/test_01-1--passing.py

Run all tests starting with test_ or ending with _test in the current working directory without traceback

$ pytest --tb=no

Run tests given by their names or (sub)directories in which they are located

$ pytest --tb=no 01-introduction/test_01-1--passing.py 01-introduction/test_01-2--failing.py
$ pytest --tb=no 01-introduction

Run only specified functions

$ pytest -v 01-introduction/test_01-1--passing.py::test_passing

Conventions to keep your test code discoverable by pytest

  • test_<something>.py or <something>_test.py for files
  • test_<something> for methods and functions
  • Test<Something> for classes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.