[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-15 Thread Steven D'Aprano
Steven D'Aprano added the comment: Matt, you can add this to your own unit tests by just subclassing unittest.TestCase and adding a new assertDuration method. Copy the existing method's implementations (its open source and you should have the source code already, but if not you can find it h

[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-15 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Thanks for the proposal Matthew, unfortunately, this addition is not reliable enough for the standard library and OTOH can be easily implemented in-situ for the users that know what the limitations are. --

[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-15 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Pablo. It is too unreliable. -- nosy: +serhiy.storchaka ___ Python tracker ___ __

[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-15 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I think this can be very error prone because a particular operation could be interrupted by GIL switching in the middle of the context manager and be reported as taking much more than the execution of the code itself is taking. This will be very confu

[issue41788] enhancement: add assertDuration context manager to unittest module

2020-09-14 Thread Matthew Davis
New submission from Matthew Davis : # Summary I propose an additional unit test type for the unittest module. TestCase.assertDuration(min=None, max=None), which is a context manager, similar to assertRaises. It runs the code inside it, and then fails the test if the duration of the code insid