nose-timer icon indicating copy to clipboard operation
nose-timer copied to clipboard

Add decorator to set timer thresholds per test

Open cryptk opened this issue 8 years ago • 6 comments

In a given test suite, some tests are expected to pass in different amounts of time. Currently with the --timer-(ok|warning|error) flags, you can only set the threshold for every test all at once. It would be really nice if there was a decorator that you could use to specify the threshold on a per-test basis.

As an example, I am testing an API where some tests are very fast (list all of your assets) and other tests take longer (create a new asset and wait for it to finish). It would be nice to be able to warn or error if the first test took more than a second, but this would be inappropriate for the latter test (which can take up to a minute).

Something like this would be great

@timer_warn(1)
@timer_error(5)
def fast_test():
    pass

@timer_warn(60)
@timer_error(120)
def slow_test():
    pass

cryptk avatar Jan 13 '17 18:01 cryptk

@mahmoudimus, what you think about this?

skudriashev avatar Mar 31 '17 09:03 skudriashev

@skudriashev @cryptk that's a seriously cool idea!

mahmoudimus avatar Mar 31 '17 16:03 mahmoudimus

@cryptk great idea! are you going to implement it or just would like to propose this feature?

e0ne avatar Jul 12 '17 19:07 e0ne

@e0ne Currently I am just proposing it as a feature, sadly I don't currently have the time to write it myself.

cryptk avatar Jul 12 '17 20:07 cryptk

Adding other proposes for the decorator: @time_warning(value=15, unit='ms') @time_error(value=15, unit='ms')

JoaoGFarias avatar Feb 14 '18 13:02 JoaoGFarias

I was thinking a timer warning exempt decorator but this would be even better!

radzhome avatar Aug 23 '21 21:08 radzhome