File: test_timer.py

package info (click to toggle)
python-throttler 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: python: 473; makefile: 4; sh: 2
file content (30 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time

import pytest

from throttler import timer, timer_async


class TestTimer:
    @pytest.mark.parametrize(
        ('verbose',), ((True,), (False,))
    )
    def test_simple(self, verbose: bool):
        @timer(name='TestTimer', verbose=verbose)
        def t():
            print(time.time())

        for _ in range(3):
            t()

    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        ('verbose',), ((True,), (False,))
    )
    async def test_simple_async(self, verbose: bool):
        @timer_async(name='TestTimer', verbose=verbose)
        async def t():
            print(time.time())

        for _ in range(3):
            await t()