Skip to main content

Pytest, but made easy

The easiest way to test your projects with pytest.

Why?

I had some tests that, when running all together, were failing due to memory issues. This is the way I solved it, and also I can log the results of my tests and clean the tests files folders very easy each time the tests are executed.

Functionality

Simplify the way we do our tests in python and run tests individually to be more accurate (and a bit slower, but is testing, accuracy is more important).

There are 2 tags:

  • mandatory for the tests that must be tested and passed always in order to go on, make a commit or upload a new version.
  • additional for the tests that are validating some optional or experimental functionality that is not needed for a commit or a new version.

You should tests always the mandatory to know that your app base code is still working, even though some experimental features could fail.

Usage

The tests folder will be your new friend. Keep a test_general.py to always do a simple test. Have the conftest.py to configure what has to be done before and after the tests are running.

Some code to apply in your tests:

  1. Test that an exception is raised with a specific message.
from pytest_easy import assert_exception_is_raised

assert_exception_is_raised(lambda: 1 / 0, exception_type = None, message = 'division by zero')
  1. Compare float values
from pytest_easy import float_approx_to_compare

assert 3.99 == float_approx_to_compare(3.99)
  1. Check that a dependency is not installed
from pytest_easy import is_dependency_installed

assert not is_dependency_installed('opencv-python')

Check test_various.py to see more examples.

This will execute the tests and remove all the new files in the test_files folder that were not before the tests were executed, or you can simply comment the test_files_handler.delete_new_files() line before running them, so the generated files are not removed in that execution, uncomment it, and they won't be removed in the next execution because they were already there.

There are some .bat files included to run the tests in 3 different modes:

  1. run_tests.bat - Non-isolated mode, normal mode.
  2. run_tests_isolated.bat - Isolated mode, our way.
  3. run_mandatory_tests.bat - Run only the tests with the @mandatory pytest mark.

Metadata

Release files for pytest-easy 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-easy 0.0.5
File Size Uploaded
pytest_easy-0.0.5.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-easy 0.0.5
File Interpreter ABI Platform
pytest_easy-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / pytest_easy-0.0.5.tar.gz

Download URL pytest_easy-0.0.5.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
333c96cd818b62acf5c34b7956436d7378a00897c0f4f687cbb139ded19edb35
BLAKE2b-256 checksum
How to use checksums
6b49d758b3bf478c7d69a680d58c9a47a5799deac16f22767bbada98de24c526
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.9.0 Windows/10

Release files / pytest_easy-0.0.5-py3-none-any.whl

Download URL pytest_easy-0.0.5-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afbabd82295cff2b4ced7b0fade8cbda03f57b53b511ddceae9df75bf81640dc
BLAKE2b-256 checksum
How to use checksums
3e1316e7836976d4e8d0031a4f2156113e281856c7b84bb856586ecdf4ed8d58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.9.0 Windows/10

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page