Skip to content

Commit a3d019c

Browse files
committed
renaming: Server -> HTTPServer
Just the "usual renaming". Also, the plugin renamed.
1 parent b86c90b commit a3d019c

4 files changed

Lines changed: 31 additions & 31 deletions

File tree

example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!.venv/bin/python3
22

3-
from pytest_httpserver.httpserver import Server
3+
from pytest_httpserver.httpserver import HTTPServer
44
import time
55
import urllib.request
66
import urllib.error
@@ -10,7 +10,7 @@ def foobar(request):
1010
return "Hello world!"
1111

1212

13-
server = Server()
13+
server = HTTPServer()
1414
server.expect_request("/foobar").respond_with_json({"foo": "bar"})
1515
server.start()
1616
try:

pytest_httpserver/httpserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def match(self, request):
110110
return None
111111

112112

113-
class Server:
113+
class HTTPServer:
114114
def __init__(self, host="localhost", port=4000):
115115
self.host = host
116116
self.port = port

pytest_httpserver/pytest_plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22

33
import pytest
4-
from .httpserver import Server
4+
from .httpserver import HTTPServer
55

66

77
@pytest.fixture
8-
def server():
9-
retval = Server()
8+
def httpserver():
9+
retval = HTTPServer()
1010
retval.start()
1111
yield retval
1212
retval.stop()

tests/test_server.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,48 @@
44
import coverage
55

66

7-
from pytest_httpserver.httpserver import Server
7+
from pytest_httpserver.httpserver import HTTPServer
88
from werkzeug.wrappers import Response
99

1010
JSON_STRING = '{"foo": "bar"}'
1111

1212

13-
def test_expected_request_json(server: Server):
14-
server.expect_request("/foobar").respond_with_json({"foo": "bar"})
15-
assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}
13+
def test_expected_request_json(httpserver: HTTPServer):
14+
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
15+
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
1616

1717

18-
def test_expected_request_data(server: Server):
19-
server.expect_request("/foobar").respond_with_data(JSON_STRING)
20-
assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}
18+
def test_expected_request_data(httpserver: HTTPServer):
19+
httpserver.expect_request("/foobar").respond_with_data(JSON_STRING)
20+
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
2121

2222

23-
def test_expected_request_handler(server: Server):
24-
server.expect_request("/foobar").respond_with_handler(lambda request: JSON_STRING)
25-
assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}
23+
def test_expected_request_handler(httpserver: HTTPServer):
24+
httpserver.expect_request("/foobar").respond_with_handler(lambda request: JSON_STRING)
25+
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
2626

2727

28-
def test_expected_request_response(server: Server):
29-
server.expect_request("/foobar").respond_with_response(Response(JSON_STRING))
30-
assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}
28+
def test_expected_request_response(httpserver: HTTPServer):
29+
httpserver.expect_request("/foobar").respond_with_response(Response(JSON_STRING))
30+
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
3131

3232

33-
def test_expected_request_response_as_string(server: Server):
34-
server.expect_request("/foobar").respond_with_response(JSON_STRING)
35-
assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}
33+
def test_expected_request_response_as_string(httpserver: HTTPServer):
34+
httpserver.expect_request("/foobar").respond_with_response(JSON_STRING)
35+
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
3636

3737

38-
def test_request_post(server: Server):
39-
server.expect_request("/foobar", data='{"request": "example"}', method="POST").respond_with_data("example_response")
40-
response = requests.post(server.url_for("/foobar"), json={"request": "example"})
41-
print(server.log[0])
42-
server.check_assertions()
38+
def test_request_post(httpserver: HTTPServer):
39+
httpserver.expect_request("/foobar", data='{"request": "example"}', method="POST").respond_with_data("example_response")
40+
response = requests.post(httpserver.url_for("/foobar"), json={"request": "example"})
41+
print(httpserver.log[0])
42+
httpserver.check_assertions()
4343
assert response.text == "example_response"
4444
assert response.status_code == 200
4545

4646

47-
def test_unexpected_request(server: Server):
48-
server.expect_request("/foobar").respond_with_json({"foo": "bar"})
49-
requests.get(server.url_for("/nonexists"))
47+
def test_unexpected_request(httpserver: HTTPServer):
48+
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
49+
requests.get(httpserver.url_for("/nonexists"))
5050
with pytest.raises(AssertionError):
51-
server.check_assertions()
51+
httpserver.check_assertions()

0 commit comments

Comments
 (0)