@@ -78,8 +78,8 @@ time setting up a complex mechanism to mock or patch the underlying Python
78
78
modules dealing with the actual HTTP request (of which there are more than one
79
79
BTW). So what do you do?
80
80
81
- You simply use pytest's `funcargs feature `_ and simulate an entire server
82
- locally! :
81
+ You simply use pytest's `fixture feature `_ and simulate an entire server
82
+ locally!
83
83
84
84
.. code :: python
85
85
@@ -107,10 +107,10 @@ The same thing works for SMTP servers, too:
107
107
def test_sending_some_message (smtpserver ):
108
108
mailer = MyMailer(host = smtpserver.addr[0 ], port = smtpserver.addr[1 ])
109
109
mailer.send(
110
-
111
-
112
- subject = " MyMailer v1.0" ,
113
- body = " Check out my mailer!"
110
+
111
+
112
+ subject = " MyMailer v1.0" ,
113
+ body = " Check out my mailer!"
114
114
)
115
115
assert len (smtpserver.outbox)== 1
116
116
@@ -144,11 +144,11 @@ suggest poking around in the code itself.
144
144
.. code :: python
145
145
146
146
httpserver.serve_content(
147
- content = None ,
148
- code = 200 ,
149
- headers = None ,
150
- chunked = pytest_localserver.http.Chunked.NO ,
151
- store_request_data = True
147
+ content = None ,
148
+ code = 200 ,
149
+ headers = None ,
150
+ chunked = pytest_localserver.http.Chunked.NO ,
151
+ store_request_data = True
152
152
)
153
153
154
154
The ``chunked `` attribute or parameter can be set to
@@ -219,7 +219,7 @@ server :
219
219
return [" success" .encode(" utf-8" )]
220
220
221
221
222
- @pytest.yield_fixture
222
+ @pytest.fixture
223
223
def testserver ():
224
224
""" Server for simple_app."""
225
225
server = WSGIServer(application = simple_app)
@@ -315,9 +315,9 @@ For package maintainers, here is how we release a new version:
315
315
Having unsuccessfully tried to mock a server, I stumbled across
316
316
`linkchecker `_ which uses a the same idea to test its internals.
317
317
318
- .. _monkeypatching : http ://pytest.org/latest /monkeypatch.html
318
+ .. _monkeypatching : https ://docs. pytest.org/en/stable/how-to /monkeypatch.html
319
319
.. _pytest : http://pytest.org/
320
- .. _ funcargs feature : http ://pytest.org/latest/funcargs .html
320
+ .. _ fixture feature : https ://pytest.org/en/stable/explanation/fixtures .html
321
321
.. _linkchecker : http://linkchecker.sourceforge.net/
322
322
.. _WSGI application : http://www.python.org/dev/peps/pep-0333/
323
323
.. _PyPI : http://pypi.python.org/pypi/pytest-localserver/
0 commit comments