module
tests.python_package_example_test
This file contains examples of how to write tests using pytest!
Some good practices for writting great Python tests:
Source: https://www.nerdwallet.com/blog/engineering/5-pytest-best-practices/
- Prefer mocker over mock
- Parametrize the same behavior, have different tests for different behaviors
- Don’t modify fixture values in other fixtures
- Prefer responses over mocking outbound HTTP requests
- Prefer tmpdir over global test artifacts
Functions
test_divide_error(a,b,expected)— Check if divide returns correct Exceptions for known entries.</>test_divide_ok(a,b,expected)— Check if divide works for expected entries.</>
A class with common parameters, param1 and param2.
function
tests.python_package_example_test.test_divide_ok(a, b, expected)
Check if divide works for expected entries.
Parameters
a(float) — Dividend.b(float) — Divisor.expected(float) — expected result.
function
tests.python_package_example_test.test_divide_error(a, b, expected)
Check if divide returns correct Exceptions for known entries.
Issue raised by https://github.com/nullhack/python-project-example/issues/1337
Parameters
a(float) — Dividend.b(float) — Divisor.expected(Exception) — expected Exception.