-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_pytest_httpretty.py
43 lines (27 loc) · 1.07 KB
/
test_pytest_httpretty.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
import sys
import httpretty
import pytest
import requests
from pytest_httpretty import stub_get
@pytest.fixture
def dummy():
return
@httpretty.activate
def test_httpretty_activate():
httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')
assert requests.get('http://example.com').text == 'Hello'
@pytest.mark.xfail(sys.version_info[0] == 2,
reason=('httpretty.activate() does not work with pytest '
'fixtures in Python 2'))
@httpretty.activate
def test_httpretty_activate_with_pytest_fixtures(dummy):
httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')
assert requests.get('http://example.com').text == 'Hello'
@pytest.mark.httpretty
def test_mark_httpretty(dummy):
httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')
assert requests.get('http://example.com').text == 'Hello'
@pytest.mark.httpretty
def test_stub_get(dummy):
stub_get('http://example.com/', body='World!')
assert requests.get('http://example.com').text == 'World!'