RunestoneInteractive / fopp

Foundations of Python Programming
https://runestone.academy/runestone/static/fopp/index.html
38 stars 120 forks source link

Assert for tests #239

Closed presnick closed 5 years ago

presnick commented 5 years ago

This is a rewrite of the Testing chapter, and also other places in the text where test.testEqual was used, substituting assert.

bnmnetp commented 5 years ago

I'm not a fan of the non-standard test module. but this isn't really representative of a real test framework. This will simply cause the program to crash at the first assertion that isn't True. That is not the same thing as test frameworks like pytest or unittest do for you. Nor is it the same as the autograding that the students will have seen so far. It may be helpful to add just a little bit more explanation about the difference between systematic unittests and sprinkling assert statements in your code.

bnmnetp commented 5 years ago

It may be useful to add a subchapter to Exceptions where we create a simple framework that calls some test_functions but catches Assertion errors and then reports the number of tests that pass and fail.