Now these are very interesting concepts, indeed.
Assertion is an efficient way of debugging in python. In it's simplest form, it returns a boolean that returns true if you assert that one thing is equivalent to another, and they are equivalent. Likewise, it will return false if the statements aren't equivalent. This is useful if you want to write a short program that analyses the output of another program. It's essentially a debugging tool so that you can run a program and see if it runs the way it is supposed to run.
Unittest is also a useful feature in python. It automates testing and allows for the testing of any given program when run. The useful if __name__ == '__main__' line allows the program to test an entire program when run. Instead of putting doctest into your program that clunks it up and doesn't do much, unittest allows for assertions and programs to run independent of the debugging and thus, keeps the original program clean and clutter free (hopefully).
Both are pretty useful items and I hope to explore them more.
No comments:
Post a Comment