Skip to main content

Assertion introspection via AST rewriting

Project description

Build Status Version

Overview

Dessert is a utility library enabling Python code to introspect assertions raised via the assert statement.

It is a standalone version of the introspection code from pytest, and all credit is due to Holger Krekel and the pytest developers for this code.

Usage

Using dessert is fairly simple:

>>> with open(tmp_filename, "w") as f:
...     _ = f.write("""
... def func():
...     def x():
...         return 1
...     def y():
...         return -1
...     assert y() == x()
... """)

>>> import emport
>>> import dessert
>>> with dessert.rewrite_assertions_context():
...     module = emport.import_file(tmp_filename)
>>> module.func() # doctest: +IGNORE_EXCEPTION_DETAIL +ELLIPSIS
Traceback (most recent call last):
    ...
    assert y() == x()
AssertionError: assert -1 == 1
+  where -1 = <function y at ...>()
+  and   1 = <function x at ...>()

Licence

Dessert is released under the MIT license. It is 99% based on pytest, which is released under the MIT license.

Project details


Download files

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

Source Distribution

dessert-1.6.3.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

dessert-1.6.3-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file dessert-1.6.3.tar.gz.

File metadata

  • Download URL: dessert-1.6.3.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dessert-1.6.3.tar.gz
Algorithm Hash digest
SHA256 a3113bd5bca112e99a968dcf74afe8841c4e370a936ebeec61b8d9dfb91b8ef6
MD5 ead879a8fc7d67521dcbf4e078da51e0
BLAKE2b-256 ea58d3e1f91d91e180b567c4cb9bf5a1208c1432b85a9abd8a8de91cae52633c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dessert-1.6.3.tar.gz:

Publisher: main.yml on getslash/dessert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dessert-1.6.3-py3-none-any.whl.

File metadata

  • Download URL: dessert-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dessert-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 512a32e3f19235a117c49ccf27b86f49a90a527320e4ba7fa99f23de45307151
MD5 a0fc2301fc3ad9f14b01457d0b83a0fc
BLAKE2b-256 6fd4d9476deed63bd421976ea5466a00c7ee0dbf342ea7283a3357fa08c620b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dessert-1.6.3-py3-none-any.whl:

Publisher: main.yml on getslash/dessert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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