Assertion introspection via AST rewriting
Project description
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
Release history Release notifications | RSS feed
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.5.0.tar.gz
(23.7 kB
view details)
Built Distribution
dessert-1.5.0-py3-none-any.whl
(21.3 kB
view details)
File details
Details for the file dessert-1.5.0.tar.gz
.
File metadata
- Download URL: dessert-1.5.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27916b1ffc932ae139385ada34ca4d2f851c66f48a2aa44295a438480fa59831 |
|
MD5 | dfc5d7f37872e4be11d7e5c5ed55aa70 |
|
BLAKE2b-256 | b39a6ae7f6d8db15a4361ae4b6a508c2583d92a7a2664c16dda7e889f5bdfb3c |
Provenance
File details
Details for the file dessert-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: dessert-1.5.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4869614762729e5c2d39864885bb1e551760bd8431abde692394a39f877ae084 |
|
MD5 | 1aa035ec0875e9eccc9227f216ae7659 |
|
BLAKE2b-256 | 8dfe510c5a66821c03768873c814dfe6b6840766f714333f77fcf24297da5de7 |