Opened 3 years ago
#6560 enhancement new
Doccument why `assert` shouldn't be used.
|Reported by:||tom.prince||Owned by:|
<_habnabit> is 'assert' supposed to be avoided or disallowed in twisted code? i saw a review comment that seemed to suggest that 'use of assert' doesn't follow the coding standard, but i couldn't find anything mentioning it <_habnabit> i was reading http://twistedmatrix.com/documents/current/core/development/policy/coding-standard.html if that's not the correct document anymore <glyph> _habnabit: Yeah <glyph> _habnabit: there are cases where you might use assert <glyph> (and somebody should really write this down) <glyph> _habnabit: In one case, you think something should be a certain way, but you haven't really tested that it shouldn't be that way, and you haven't tested any code that deals with it being that way <glyph> in which case you should delete the assert because honestly you don't care enough to make sure that it's not that way <glyph> In the other case, you care that the AssertionError is raised, and you have some tests which makes sure it happens, and happens with a comprehensible error message <_habnabit> aha <glyph> in which case you should delete the assert because you should have a more specific exception type. <_habnabit> heh <_habnabit> okay, that's clear <glyph> (since all those tests will start failing if you use python -O)
Change History (0)
Note: See TracTickets for help on using tickets.