mahmoudimus / nose-timer

A timer plugin for nosetests (how much time does every test take?)
MIT License
126 stars 33 forks source link

Add decorator to set timer thresholds per test #80

Open cryptk opened 7 years ago

cryptk commented 7 years ago

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
skudriashev commented 7 years ago

@mahmoudimus, what you think about this?

mahmoudimus commented 7 years ago

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

e0ne commented 7 years ago

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

cryptk commented 7 years ago

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

JoaoGFarias commented 6 years ago

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

radzhome commented 3 years ago

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