Skip to content

Repository files navigation

Build StatusVersion

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:

>>>withopen(tmp_filename, "w") asf:
... _=f.write("""... def func():... def x():... return 1... def y():... return -1... assert y() == x()... """)
>>>importemport>>>importdessert>>>withdessert.rewrite_assertions_context():
... module=emport.import_file(tmp_filename)
>>>module.func() # doctest: +IGNORE_EXCEPTION_DETAIL +ELLIPSISTraceback (mostrecentcalllast):
...
asserty() ==x()
AssertionError: assert-1==1+where-1=<functionyat ...>()
+and1=<functionxat ...>()

Licence

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

About

Standalone version of pytest's assertion introspection rewrite

Topics

Resources

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages