Completed
Push — master ( 0887a7...b18166 )
by Ionel Cristian
59s
created

tests.test_fast()   B

Complexity

Conditions 5

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 5
dl 0
loc 8
rs 8.5454

1 Method

Rating   Name   Duplication   Size   Complexity  
A tests.result() 0 3 1
1
"""
2
Just to make sure the plugin doesn't choke on doctests::
3
4
    >>> print('Yay, doctests!')
5
    Yay, doctests!
6
7
"""
8
import time
9
from functools import partial
10
11
import pytest
12
13
14
def test_fast(benchmark):
15
    @benchmark
16
    def result():
17
        return time.sleep(0.000001)
18
    assert result is None
19
20
    if not benchmark.disabled:
21
        assert benchmark.stats.min >= 0.000001
22
23
24
def test_slow(benchmark):
25
    assert benchmark(partial(time.sleep, 0.001)) is None
26
27
28
def test_slower(benchmark):
29
    benchmark(lambda: time.sleep(0.01))
30
31
32
# @pytest.mark.benchmark(min_rounds=2, timer=time.time, max_time=0.01)
33
# def test_xfast(benchmark):
34
#     benchmark(str)
35
36
37
@pytest.fixture(params=range(5))
38
def foo(request):
39
    return request.param
40
41
42
def test_parametrized(benchmark, foo):
43
    benchmark(time.sleep, 0.00001)
44
    if benchmark.enabled:
45
        assert benchmark.stats.min >= 0.00001
46