3 ms·
As a bit of a joke I wrote a library for this once https://github.com/boothby/dissert https://github.com/boothby/dissert The big problem is that some people u
by boothby 3y ago
As a bit of a joke I wrote a library for this once
https://github.com/boothby/dissert https://github.com/boothby/dissert
The big problem is that some people use assert wrong. There's a distinct time and place for asserts, and that's for testing purely internal logic. If you're testing anything that can be tainted with user data, that must be done with a conditional & exception.
Dissert saves the day! You can disable asserts on a per-file basis, and get that PYTHONOPTIMIZE experience with no perceived loss of safety. Of course, it uses the horrid content-encoding hack to trim assertions out of your code, so I make no guarantees.