File: test_param.py

package info (click to toggle)
pytest-tornado 0.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168 kB
  • sloc: python: 502; makefile: 19; sh: 1
file content (74 lines) | stat: -rw-r--r-- 1,536 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import pytest
from tornado import gen

DUMMY_PARAMS = ['f00', 'bar']


@pytest.fixture(params=DUMMY_PARAMS)
def _dummy(request):
    return request.param


@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
])
def test_eval(input, expected):
    assert eval(input) == expected


@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
    pytest.param("6*9", 42,
                 marks=pytest.mark.xfail),
])
def test_eval_marking(input, expected):
    assert eval(input) == expected


@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
])
@pytest.mark.gen_test
def test_sync_eval_with_gen_test(input, expected):
    assert eval(input) == expected


@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
])
def test_eval_with_fixtures(input, io_loop, expected):
    assert eval(input) == expected


def test_param_fixture(_dummy):
    assert _dummy in DUMMY_PARAMS


@pytest.mark.gen_test
@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
])
def test_gen_test_parametrize(io_loop, input, expected):
    yield gen.sleep(0)
    assert eval(input) == expected


@pytest.mark.parametrize('input,expected', [
    ('3+5', 8),
    ('2+4', 6),
])
@pytest.mark.gen_test
def test_gen_test_fixture_any_order(input, io_loop, expected):
    yield gen.sleep(0)
    assert eval(input) == expected


@pytest.mark.gen_test
def test_gen_test_param_fixture(io_loop, _dummy):
    yield gen.sleep(0)
    assert _dummy in DUMMY_PARAMS