[TIP] Common library for assertion rewriting
FELD Boris
lothiraldan at gmail.com
Sat Dec 10 13:45:27 PST 2011
Hello everyone, I tried last days to write a common library for rewriting assertions (like pytest does). I tried to make it the more flexible possible in order to be used on test libraries.
The source code is available at https://bitbucket.org/lothiraldan/assert_hook. A working example can be executed by launching the launch.py module.
The idea is to replace traditionnals assert (like assert 1 == 3) by calling a custom function (assert_hook.new_assert("1 == 3')).
You can use assert_hook as a library using this piece of code:
> > > import assert_hook
> > > assert_hook.new_assert = YOUR_CUSTOM_ASSERT
It support python3 and custom assertions messages.
I hope you will find this code helpfull, all contributions and feedbacks are welcome.
More information about the testing-in-python
mailing list