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.4.1.tar.gz
(33.7 kB
view details)
File details
Details for the file dessert-1.4.1.tar.gz
.
File metadata
- Download URL: dessert-1.4.1.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89b1369c97ce66c3dfd3201b68080609be1a1ee4666faf4daa30bdb310d14fde |
|
MD5 | 17dbdad2ed8299308079ef48e82b4224 |
|
BLAKE2b-256 | 65aae79b819bceabc96204e6b3c90728c9aea3b3143cb992df29390dddf695f7 |