https://github.com/mvousden/pytest-lets-explore
A foray into the features of pytest.
https://github.com/mvousden/pytest-lets-explore
lets-explore mock mocking parallel pytest pytest-mock pytest-plugin pytest-xdist python python3 python36
Last synced: 11 months ago
JSON representation
A foray into the features of pytest.
- Host: GitHub
- URL: https://github.com/mvousden/pytest-lets-explore
- Owner: mvousden
- Created: 2017-11-25T14:11:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-26T19:50:44.000Z (over 8 years ago)
- Last Synced: 2025-02-10T04:31:56.825Z (about 1 year ago)
- Topics: lets-explore, mock, mocking, parallel, pytest, pytest-mock, pytest-plugin, pytest-xdist, python, python3, python36
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
About
---
Welcome to "let's explore pytest", which includes several pytest
examples. pytest is a testing framework that can be used to test Python code,
amongst other things, and lives at www.pytest.org. Python 3 is used exclusively
in this repository, though pytest can test Python 2 software.
These examples assume you are familiar with your shell or commandline, and are
able to set up your environment appropriately.
Environment
---
You will need (the versions we are using are in parentheses):
- Python 3 (3.6.2)
- pytest (3.2.1)
- pytest-mock (1.6.0)
- pytest-xdist (1.17.1)
The conda environment file `conda_environment.yml` is provided, which all
examples are designed to use.
Table of contents
---
Each example contains multiple `pytest` Python scripts.
1. *Introductory examples*
- Introduces pytest.
- pytest reports failing tests, and has informative output.
- pytest searches for tests automatically.
2. *Fixtures, parameterisation, and parallelisation* (requires example 1)
- Fixtures (decorated with `@pytest.fixture()`) are blocks of functionality
that allow tests to be written in a modular way.
- Fixtures are run when the test is run, and their output is passed to the
test.
- Fixtures can be used to parameterise tests, reducing code
duplication. Each test is run individually of the others.
- Parameterised tests run well in parallel (but be careful when testing
software that itself runs in parallel!)
3. *Testing software in isolation using mocking* (requires example 2)