Skip to content

Commit 5ccb70d

Browse files
committed
Adding windows to CI
1 parent e506288 commit 5ccb70d

File tree

7 files changed

+149
-72
lines changed

7 files changed

+149
-72
lines changed

Diff for: .travis.yml

+31-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
1-
language: python
2-
31
cache: pip
42

5-
python:
6-
- "3.5"
7-
- "3.6"
8-
- "3.7-dev"
3+
language: python
4+
5+
matrix:
6+
include:
7+
# The Windows job is important (obviously) to test on a non-Unix platform.
8+
# It also runs the test with a quite minimal setup (no uvloop or httptools),
9+
# but it does have websockets (needed to run the websockets tests).
10+
- os: windows
11+
language: bash
12+
# The pypy3 job runs a fully pure Python setup, which triggers a part of the
13+
# auto-detect tests that the other tests don't. We cannot test websockets though.
14+
- os: linux
15+
python: "pypy3.5"
16+
# The main tests run on Linux for a all relevant Python versions.
17+
- os: linux
18+
python: "3.5"
19+
- os: linux
20+
python: "3.6"
21+
- os: linux
22+
python: "3.7-dev"
923

1024
install:
11-
- pip install -U -r requirements.txt
25+
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
26+
choco install python3;
27+
export PATH=/c/Python37:/c/Python37/Scripts:$PATH;
28+
python -m pip install click h11 wsproto websockets;
29+
python -m pip install autoflake black codecov isort pytest pytest-cov requests;
30+
elif [ "$TRAVIS_PYTHON_VERSION" = "pypy3.5" ]; then
31+
python -m pip install click h11 wsproto;
32+
python -m pip install pytest pytest-cov requests codecov;
33+
else
34+
pip install -U -r requirements.txt;
35+
fi;
1236

1337
script:
1438
- scripts/test

Diff for: tests/__init__.py

Whitespace-only changes.

Diff for: tests/protocols/test_http.py

+45-38
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
import h11
44
import pytest
5-
6-
from tests.response import Response
75
from uvicorn.config import Config
86
from uvicorn.main import ServerState
97
from uvicorn.protocols.http.h11_impl import H11Protocol
10-
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
118
from uvicorn.protocols.websockets.wsproto_impl import WSProtocol
129

10+
from tests.response import Response
11+
12+
try:
13+
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
14+
except ImportError:
15+
HttpToolsProtocol = None
16+
17+
18+
HTTP_PROTOCOLS = [p for p in [H11Protocol, HttpToolsProtocol] if p is not None]
19+
1320
SIMPLE_GET_REQUEST = b"\r\n".join([b"GET / HTTP/1.1", b"Host: example.org", b"", b""])
1421

1522
SIMPLE_HEAD_REQUEST = b"\r\n".join([b"HEAD / HTTP/1.1", b"Host: example.org", b"", b""])
@@ -144,7 +151,7 @@ def get_connected_protocol(app, protocol_cls, **kwargs):
144151
return protocol
145152

146153

147-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
154+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
148155
def test_get_request(protocol_cls):
149156
def app(scope):
150157
return Response("Hello, world", media_type="text/plain")
@@ -156,7 +163,7 @@ def app(scope):
156163
assert b"Hello, world" in protocol.transport.buffer
157164

158165

159-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
166+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
160167
def test_head_request(protocol_cls):
161168
def app(scope):
162169
return Response("Hello, world", media_type="text/plain")
@@ -168,7 +175,7 @@ def app(scope):
168175
assert b"Hello, world" not in protocol.transport.buffer
169176

170177

171-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
178+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
172179
def test_post_request(protocol_cls):
173180
class App:
174181
def __init__(self, scope):
@@ -191,7 +198,7 @@ async def __call__(self, receive, send):
191198
assert b'Body: {"hello": "world"}' in protocol.transport.buffer
192199

193200

194-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
201+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
195202
def test_keepalive(protocol_cls):
196203
def app(scope):
197204
return Response(b"", status_code=204)
@@ -204,7 +211,7 @@ def app(scope):
204211
assert not protocol.transport.is_closing()
205212

206213

207-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
214+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
208215
def test_keepalive_timeout(protocol_cls):
209216
def app(scope):
210217
return Response(b"", status_code=204)
@@ -223,7 +230,7 @@ def app(scope):
223230
assert protocol.transport.is_closing()
224231

225232

226-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
233+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
227234
def test_close(protocol_cls):
228235
def app(scope):
229236
return Response(b"", status_code=204, headers={"connection": "close"})
@@ -235,7 +242,7 @@ def app(scope):
235242
assert protocol.transport.is_closing()
236243

237244

238-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
245+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
239246
def test_chunked_encoding(protocol_cls):
240247
def app(scope):
241248
return Response(
@@ -250,7 +257,7 @@ def app(scope):
250257
assert not protocol.transport.is_closing()
251258

252259

253-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
260+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
254261
def test_chunked_encoding_empty_body(protocol_cls):
255262
def app(scope):
256263
return Response(
@@ -265,7 +272,7 @@ def app(scope):
265272
assert not protocol.transport.is_closing()
266273

267274

268-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
275+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
269276
def test_chunked_encoding_head_request(protocol_cls):
270277
def app(scope):
271278
return Response(
@@ -279,7 +286,7 @@ def app(scope):
279286
assert not protocol.transport.is_closing()
280287

281288

282-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
289+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
283290
def test_pipelined_requests(protocol_cls):
284291
def app(scope):
285292
return Response("Hello, world", media_type="text/plain")
@@ -305,7 +312,7 @@ def app(scope):
305312
protocol.transport.clear_buffer()
306313

307314

308-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
315+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
309316
def test_undersized_request(protocol_cls):
310317
def app(scope):
311318
return Response(b"xxx", headers={"content-length": "10"})
@@ -316,7 +323,7 @@ def app(scope):
316323
assert protocol.transport.is_closing()
317324

318325

319-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
326+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
320327
def test_oversized_request(protocol_cls):
321328
def app(scope):
322329
return Response(b"xxx" * 20, headers={"content-length": "10"})
@@ -327,7 +334,7 @@ def app(scope):
327334
assert protocol.transport.is_closing()
328335

329336

330-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
337+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
331338
def test_large_post_request(protocol_cls):
332339
def app(scope):
333340
return Response("Hello, world", media_type="text/plain")
@@ -339,15 +346,15 @@ def app(scope):
339346
assert not protocol.transport.read_paused
340347

341348

342-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
349+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
343350
def test_invalid_http(protocol_cls):
344351
app = lambda scope: None
345352
protocol = get_connected_protocol(app, protocol_cls)
346353
protocol.data_received(b"x" * 100000)
347354
assert protocol.transport.is_closing()
348355

349356

350-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
357+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
351358
def test_app_exception(protocol_cls):
352359
class App:
353360
def __init__(self, scope):
@@ -363,7 +370,7 @@ async def __call__(self, receive, send):
363370
assert protocol.transport.is_closing()
364371

365372

366-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
373+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
367374
def test_app_init_exception(protocol_cls):
368375
def app(scope):
369376
raise Exception()
@@ -375,7 +382,7 @@ def app(scope):
375382
assert protocol.transport.is_closing()
376383

377384

378-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
385+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
379386
def test_exception_during_response(protocol_cls):
380387
class App:
381388
def __init__(self, scope):
@@ -393,7 +400,7 @@ async def __call__(self, receive, send):
393400
assert protocol.transport.is_closing()
394401

395402

396-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
403+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
397404
def test_no_response_returned(protocol_cls):
398405
class App:
399406
def __init__(self, scope):
@@ -409,7 +416,7 @@ async def __call__(self, receive, send):
409416
assert protocol.transport.is_closing()
410417

411418

412-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
419+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
413420
def test_partial_response_returned(protocol_cls):
414421
class App:
415422
def __init__(self, scope):
@@ -425,7 +432,7 @@ async def __call__(self, receive, send):
425432
assert protocol.transport.is_closing()
426433

427434

428-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
435+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
429436
def test_duplicate_start_message(protocol_cls):
430437
class App:
431438
def __init__(self, scope):
@@ -442,7 +449,7 @@ async def __call__(self, receive, send):
442449
assert protocol.transport.is_closing()
443450

444451

445-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
452+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
446453
def test_missing_start_message(protocol_cls):
447454
class App:
448455
def __init__(self, scope):
@@ -458,7 +465,7 @@ async def __call__(self, receive, send):
458465
assert protocol.transport.is_closing()
459466

460467

461-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
468+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
462469
def test_message_after_body_complete(protocol_cls):
463470
class App:
464471
def __init__(self, scope):
@@ -476,7 +483,7 @@ async def __call__(self, receive, send):
476483
assert protocol.transport.is_closing()
477484

478485

479-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
486+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
480487
def test_value_returned(protocol_cls):
481488
class App:
482489
def __init__(self, scope):
@@ -494,7 +501,7 @@ async def __call__(self, receive, send):
494501
assert protocol.transport.is_closing()
495502

496503

497-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
504+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
498505
def test_early_disconnect(protocol_cls):
499506
got_disconnect_event = False
500507

@@ -520,7 +527,7 @@ async def __call__(self, receive, send):
520527
assert got_disconnect_event
521528

522529

523-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
530+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
524531
def test_early_response(protocol_cls):
525532
def app(scope):
526533
return Response("Hello, world", media_type="text/plain")
@@ -533,7 +540,7 @@ def app(scope):
533540
assert not protocol.transport.is_closing()
534541

535542

536-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
543+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
537544
def test_read_after_response(protocol_cls):
538545
message_after_response = None
539546

@@ -555,7 +562,7 @@ async def __call__(self, receive, send):
555562
assert message_after_response == {"type": "http.disconnect"}
556563

557564

558-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
565+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
559566
def test_http10_request(protocol_cls):
560567
def app(scope):
561568
content = "Version: %s" % scope["http_version"]
@@ -568,7 +575,7 @@ def app(scope):
568575
assert b"Version: 1.0" in protocol.transport.buffer
569576

570577

571-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
578+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
572579
def test_root_path(protocol_cls):
573580
def app(scope):
574581
path = scope.get("root_path", "") + scope["path"]
@@ -581,7 +588,7 @@ def app(scope):
581588
assert b"Path: /app/" in protocol.transport.buffer
582589

583590

584-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
591+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
585592
def test_max_concurrency(protocol_cls):
586593
app = lambda scope: None
587594
protocol = get_connected_protocol(app, protocol_cls, limit_concurrency=1)
@@ -590,7 +597,7 @@ def test_max_concurrency(protocol_cls):
590597
assert b"HTTP/1.1 503 Service Unavailable" in protocol.transport.buffer
591598

592599

593-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
600+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
594601
def test_shutdown_during_request(protocol_cls):
595602
def app(scope):
596603
return Response(b"", status_code=204)
@@ -603,7 +610,7 @@ def app(scope):
603610
assert protocol.transport.is_closing()
604611

605612

606-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
613+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
607614
def test_shutdown_during_idle(protocol_cls):
608615
app = lambda scope: None
609616
protocol = get_connected_protocol(app, protocol_cls)
@@ -612,7 +619,7 @@ def test_shutdown_during_idle(protocol_cls):
612619
assert protocol.transport.is_closing()
613620

614621

615-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
622+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
616623
def test_100_continue_sent_when_body_consumed(protocol_cls):
617624
class App:
618625
def __init__(self, scope):
@@ -647,7 +654,7 @@ async def __call__(self, receive, send):
647654
assert b'Body: {"hello": "world"}' in protocol.transport.buffer
648655

649656

650-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
657+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
651658
def test_100_continue_not_sent_when_body_not_consumed(protocol_cls):
652659
def app(scope):
653660
return Response(b"", status_code=204)
@@ -670,7 +677,7 @@ def app(scope):
670677
assert b"HTTP/1.1 204 No Content" in protocol.transport.buffer
671678

672679

673-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
680+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
674681
def test_unsupported_upgrade_request(protocol_cls):
675682
def app(scope):
676683
pass # pragma: no cover
@@ -681,7 +688,7 @@ def app(scope):
681688
assert b"Unsupported upgrade request." in protocol.transport.buffer
682689

683690

684-
@pytest.mark.parametrize("protocol_cls", [HttpToolsProtocol, H11Protocol])
691+
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
685692
def test_supported_upgrade_request(protocol_cls):
686693
def app(scope):
687694
pass # pragma: no cover

0 commit comments

Comments
 (0)