patchwork
patchwork copied to clipboard
Add test_randomly
For exercising Patchwork with random inputs.
Implementation notes:
-
I don't know if the code involving threading is correct.
-
Leave many TODOs, because doing them would good, but isn't crucial for the random test to be useful.
-
Some identifiers have a trailing underscore (hypothesis_) in order to avoid shadowing global variables.
-
One might think that starting a thread for every act() is slow, but on my machine, which is old, it increases the running time of the random test by only a few seconds (7 s → 8-12 s).
-
Someone in https://stackoverflow.com/questions/2829329/ advises to catch BaseException (instead of Exception) and re-raise in (Terminable)Thread.join. Don't do that, because a SystemExit in a child thread shouldn't terminate the parent, in my opinion.
-
Custom exception types are good. Cf. https://www.youtube.com/watch?v=wf-BqAjZb8M.