forked from taverntesting/tavern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_call_run.py
66 lines (48 loc) · 1.55 KB
/
test_call_run.py
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
import warnings
from unittest.mock import patch
import pytest
from tavern._core import exceptions
from tavern.core import run
@pytest.fixture(autouse=True)
def patch_pytest():
with patch("tavern.core.pytest.main") as fake_main:
yield
assert fake_main.called
class TestBasicRun:
def test_run(self):
run("")
def test_run_with_empty_cfg(self):
run("", {})
def test_run_with_cfg(self):
run("", {"a": 2})
@pytest.mark.parametrize(
"expected_kwarg",
(
"tavern_mqtt_backend",
"tavern_http_backend",
"tavern_grpc_backend",
"tavern_strict",
),
)
def test_doesnt_warn_about_expected_kwargs(self, expected_kwarg):
kw = {expected_kwarg: 123}
with warnings.catch_warnings():
warnings.simplefilter("error")
run("", **kw)
class TestParseGlobalCfg:
def test_path_correct(self):
run("", tavern_global_cfg=__file__)
def test_pass_dict(self):
run("", tavern_global_cfg={"variables": {"a": 1}})
class TestParseFailures:
@pytest.fixture(autouse=True)
def patch_pytest(self):
with patch("tavern.core.pytest.main") as fake_main:
yield
assert not fake_main.called
def test_path_nonexistent(self):
with pytest.raises(exceptions.InvalidSettingsError):
run("", tavern_global_cfg="sdfsdd")
def test_bad_type(self):
with pytest.raises(exceptions.InvalidSettingsError):
run("", tavern_global_cfg=["a", "b", "c"])