Skip to main content

Timeout and Duration decorator for python unittest.Testcase

Project description

Duration Check

Working python decorators to check how long function can take to be executed.

Decorator available

  • timeout via timeout_decorator_builder()
  • duration

Code example

import sys
import unittest

from duration_check import timeout_decorator_builder

# This CAN NOT be a lambda function because we can't pickle them
def module_getter():
    return sys.modules[__name__]

timeout = timeout_decorator_builder(module_getter)  # This CAN NOT be a lambda function because we can't pickle them

class SuperTaskUnitTest(unittest.TestCase):

    @timeout(2)
    def test_timeout_super_task(self):
        self.assertTrue(my_super_task())

Issues/Bug report or improvement ideas

https://gitlab.com/devolive/pypi-packages/duration-check/-/issues

License

GNU Lesser General Public License v3 or later (LGPLv3+)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

duration_check-1.0.4.tar.gz (5.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page