PyUnit - How to unit test a method that runs into an infinite loop for some input?
问题 A post in 2011 answered this question for NUnit: How to unit test a method that runs into an infinite loop for some input? Is there a similar TimeoutAttribute in PyUnit that I can use in the same fashion? I did some searching and found "Duration", but that didn't seem the same. 回答1: There doesn't appear there is anything in pyunit itself, but as a work around you can roll your own. Here is how to do it using the multiprocessing package. from functools import wraps from multiprocessing import