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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_easy-0.0.5.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_easy-0.0.5-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_easy-0.0.5.tar.gz.

File metadata

  • Download URL: pytest_easy-0.0.5.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.9.0 Windows/10

File hashes

Hashes for pytest_easy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 333c96cd818b62acf5c34b7956436d7378a00897c0f4f687cbb139ded19edb35
MD5 5b9d9240fceab8cab3b68ac7b9b4cd6f
BLAKE2b-256 6b49d758b3bf478c7d69a680d58c9a47a5799deac16f22767bbada98de24c526

See more details on using hashes here.

File details

Details for the file pytest_easy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pytest_easy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.9.0 Windows/10

File hashes

Hashes for pytest_easy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 afbabd82295cff2b4ced7b0fade8cbda03f57b53b511ddceae9df75bf81640dc
MD5 2c3e254f2ddb87f89182253734d88704
BLAKE2b-256 3e1316e7836976d4e8d0031a4f2156113e281856c7b84bb856586ecdf4ed8d58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page