Skip to content
/ pytesting Public

Demo code for testing with Pytest and Hypothesis

License

Notifications You must be signed in to change notification settings

4OH4/pytesting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d553362 · May 25, 2020

History

36 Commits
Jan 4, 2020
Jan 4, 2020
May 25, 2020
Nov 19, 2019
May 25, 2020
Dec 27, 2019
Dec 1, 2019
Nov 15, 2019
May 19, 2020
May 19, 2020
May 19, 2020
Jan 4, 2020

Repository files navigation

License: MIT Build Status - Travis Build Status - GitHub Coverage Status

pytesting

Unit testing, code coverage and mocking with Pytest, and property-based testing with Hypothesis.

https://github.com/4OH4/pytesting

This repository is the companion code for a forthcoming blog post on Python software testing. Feedback encouraged - please raise an issue.

Quickstart

Clone the repository, install requirements into your Python environment and run the tests:

git clone https://github.com/4OH4/pytesting
cd pytesting
pip install -r requirements.txt
python run_tests.py

Quickstart with Docker

Clone the repository and run everything inside a Docker container:

git clone https://github.com/4OH4/pytesting
cd pytesting/Docker
docker-compose -d up
docker-compose run pytesting
python run_tests.py

Setup and requirements

Python 3 and the following packages (all available via pip):

  • pytest
  • pytest-cov
  • pytest-mock
  • pytruth
  • hypothesis

Or install via the requirements.txt file:

pip install -r requirements.txt

Running test cases

Tests should be run from the command line, in the repository root.

Doctest

Doctests are executed for a single module at a time. The command runs the tests in database.py (for example):

python -m doctest -v src/database.py

The -v argument requests verbose output - otherwise it only reports test failures.

Pytest

To run all test cases:

pytest

To run the code coverage report:

pytest --cov=src tests

About

Demo code for testing with Pytest and Hypothesis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published