Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's the best idea I've seen in a long time. Give an expr, get a value, and if you like it, type something meaning "add a test that evals that expr and expects the value I just saw". The only risk is convincing yourself that what you got looks right when it's actually not.


doctest comes with Python. You paste from REPL sessions into doccomments, and use a little utility function to automatically find/run them.

It's not as useful as you'd think -- the only way to structure the tests is by the class or function the comment is on, and you have to go out of your way to avoid default __repr__ returns of the form "<object foo at 0xADDRESS>", as the expected response handling is ANAL.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: