nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 396 forks source link

timed() now enforces time limit. #982

Open belisarius222 opened 8 years ago

belisarius222 commented 8 years ago

The timed() decorator used to wait indefinitely for its test function to return. Now it runs the test function in a new thread, and if the function doesn't return within the specified time limit, it throws a TimeExpired error.

jszakmeister commented 8 years ago

What happens when the function doesn't return in the specified time frame? Does it kill the thread? That would be really bad. Is there a chance that it's going to interfere with other running tests? I don't think I like this direction, personally.

belisarius222 commented 8 years ago

Ok.

I can see how this might not be the best direction for nose, considering how general it needs to be. Adding a thread does introduce more complexity, and now that you mention it, I can see some troublesome edge cases. It should really run the function's teardown if it didn't complete, for example.

I felt compelled to write this because I kept putting @timed() decorators on tests, expecting the decorator to flag them as failures if they didn't complete in time, but instead the test will continue on, even if it's hanging. I need something like this function to test certain pieces of code that tend to hang if they're not working properly, mostly multiprocessing-related.