Skip to main content

JET demo

Installation • Basic Usage • Mastering Verbosity • Custom Fail Conditions • Customization

JET is a testing library for python aimed at being fast to set up, easy to use and above all pleasing to the eye. Because testing does not have to be a chore to set up, clutter the terminal or ugly to look at.

JET demo

Installation

Note JET requires gum to be installed and available on your PATH.

Best way to install jet is through pip:

pip install jet-test

Usage

Running Tests

jet run <option>
  • --all: Run all test modules. Skips initial module selection.
  • --dir: Path to tests directory. Defaults to /tests when not supplied.
  • --files: List of modules to consider instead of entire directory.
  • --quiet: Disable test ouput verbose as they run.
  • --n-jobs: Number of processes to use in parallel when running tests. Defaults to one.
  • --percentage: Whether to show progress as a percentage instead of count.

JET demo

JET searches for the tests folder in your working directory and runs all tests that start with test_* from the modules named as: test_<something>.py. JET starts by prompting you to choose wich modules to run. You can run all of them by selecting "Run All" or use the --all flag, check the run command for more options.

Reading Reports

jet see <option>

Specific options for the see command:

  • --dir: Path to tests directory. Defaults to /tests when not supplied.
  • --doc-width: Width (number of columns collumns) of report doc.
  • --text-width: Width (number of columns collumns) of text blocks in report.
  • --buffer: Number of lines of code to show in the report.

JET demo

All tests that did not conclude with a "pass" can be further inspected. To see a detailed report including, captured standard output, local variables, source code and error description run the see command. The report is colapsable as to display as much information as possible without cluttering your terminal.

Mastering Verbosity

Test Routines

JET displays the result of each test after it has been run, unless the --quiet flag is raised.

  • if it passes : It displays the tests's doc. If no doc is available, it shows the test's name.
  • else : Display's the error/warning/failing condition description. If no description is provided, it shows the doc or name of test. This behaviour is specially usefull of a test has more than one failing condition, for example:
#tests have to start with test_
def test_example():
   """This is the text that will be display if the test passes"""
   a = 1
   b = 2
   assert a == 1, "Text displayed if a is not equal to 1"
   assert b == 2, "Text displayed if b is not equal to 2"

JET demo

Test Modules

JET searches for modules named: test_<something>.py in the tests/ directory (for a different directory use --dir). When prompting the user JET will display "Seomthing" as the module title and the module __doc__ as the description. The descripiton will be blank if JET otherwise. For creating a __doc__ for a python module add:

"""This is a module documentation.
It should be the first line in any python module
"""

#defines all tests below
def test_whatever():...

Custom Fail Conditions

Suppose you want a test to fail if it's running time exceeds 0.5 seconds. We do that by creating a wrapper that raises a custom error when the condition is failed.

def timebounded(test_function):
    """Example wrapper for a custom suport.
    Throws an error if the wrapped function exceeds a certain amount of time to run"""

    @wraps(test_function)
    def wrappee():
        elapsed = timeit.timeit(test_function, number=1)
        if elapsed > 0.5:
            raise PatienceError(
                f"CUSTOM ERROR: The function called {test_function.__name__} exceded my patience"
            )

    return wrappee


@timebounded
def test_timings_of_calculation():
    """The function should not exeed 0.5 seconds."""
    time.sleep(1)

The custom error and description and variables will show up both on the run erbose but also in the error report. This example can easily be expanded to add different and more complex failing conditions such as memory allocation and network usage etc.

JET demo

Further Customizations

Global JET customization options:

jet <option> <command>
  • --foreground: color (hex, rgb or terminal256) for foreground elements.
  • --background: color (hex, rgb or terminal256) for background.
  • --pass-color: color (hex, rgb or terminal256) for pass tests.
  • --failed-color: color (hex, rgb or terminal256) for failed tests.
  • --error-color: color (hex, rgb or terminal256) for tests that result in errors.
  • --warning-color: color (hex, rgb or terminal256) for tests that throw warnings.

JET demo

Metadata

Release files for jet-test 0.0.3

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

Source distribution (sdist)

Source distribution for jet-test 0.0.3
File Size Uploaded Provenance Actions
jet-test-0.0.3.tar.gz 14.7 kB Without provenance Details for jet-test-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jet-test 0.0.3
File Interpreter ABI Platform Actions
jet_test-0.0.3-py3-none-any.whl Python 3 none any Details for jet_test-0.0.3-py3-none-any.whl

Total release size: 29.7 kB

Release files / jet-test-0.0.3.tar.gz

Download URL jet-test-0.0.3.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d426a0e23394b91701a9eb64c79cf486db2e1cc5dceddbb3a55cbee8f6be08c1
BLAKE2b-256 checksum
How to use checksums
5a3c4e7d709278ade7544b08884d2f5f60a202661de4e5c04e265755be84fbd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / jet_test-0.0.3-py3-none-any.whl

Download URL jet_test-0.0.3-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3925fb5e629b3b45f84debea457d002ff83a9eb19e03ff12b103efa0b402c8f2
BLAKE2b-256 checksum
How to use checksums
034396880c88612bd8cf13bde1ffe2e2275a64845629ee14d2d3f580133acc56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for jet-test 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files No provenance

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