Skip to content

Commit 1f21aae

Browse files
committed
Don't allow external requests in the tests by default
1 parent ffbfacc commit 1f21aae

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pytest
2+
3+
4+
@pytest.fixture(autouse=True)
5+
def no_requests(request, monkeypatch):
6+
if request.node.get_marker('requests'):
7+
return
8+
9+
def func(session, method, url, *args, **kwargs):
10+
pytest.fail(
11+
"Session.request() not allowed during tests. (%s %s, %r, %r)" %
12+
(method, url, args, kwargs))
13+
14+
monkeypatch.setattr("requests.sessions.Session.request", func)

tests/test_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_get_port_service_port():
2222
assert port
2323

2424

25+
@pytest.mark.requests
2526
def test_service_proxy():
2627
client_obj = client.Client('tests/wsdl_files/soap.wsdl')
2728

@@ -45,6 +46,7 @@ def test_service_proxy():
4546
assert result == 120.123
4647

4748

49+
@pytest.mark.requests
4850
def test_call_method_fault():
4951
obj = client.Client('tests/wsdl_files/soap.wsdl')
5052

tests/test_wsdl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self):
1717
return DummyWSDL()
1818

1919

20+
@pytest.mark.requests
2021
def test_parse_soap_wsdl():
2122
transport = Transport()
2223

@@ -73,6 +74,7 @@ def test_parse_soap_wsdl():
7374
assert_nodes_equal(expected, request.body)
7475

7576

77+
@pytest.mark.requests
7678
def test_parse_soap_header_wsdl():
7779
transport = Transport()
7880

0 commit comments

Comments
 (0)