forked from jaraco/jaraco.abode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
37 lines (25 loc) · 782 Bytes
/
conftest.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
import urllib.parse
import pytest
import jaraco.abode
collect_ignore = ['abodepy']
@pytest.fixture(autouse=True)
def abode_instance(request):
if request.instance is None:
return
request.instance.abode = jaraco.abode.Abode(
username='foobar', password='deadbeef', disable_cache=True
)
def wrap_mock_register_uri(mocker):
"""
Allow path to omit the leading /
"""
orig = mocker.register_uri
def register_uri(method, url, *args, **kwargs):
if not urllib.parse.urlparse(url).path.startswith('/'):
url = '/' + url
return orig(method, url, *args, **kwargs)
mocker.register_uri = register_uri
return mocker
@pytest.fixture
def m(requests_mock):
return wrap_mock_register_uri(requests_mock)