Skip to content

Commit

Permalink
Enable windows CI (#4176)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Oct 14, 2019
1 parent 36e8a95 commit bbaf125
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 50 deletions.
16 changes: 8 additions & 8 deletions .azure-pipelines/stage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ stages:
# python.version: 'pypy3'
# no_extensions: 'Y'
# image: 'ubuntu-latest'
# Py36-Cython-Win:
# python.version: '3.6'
# no_extensions: ''
# image: 'windows-latest'
# Py37-Cython-Win:
# python.version: '3.7'
# no_extensions: ''
# image: 'windows-latest'
Py36-Cython-Win:
python.version: '3.6'
no_extensions: ''
image: 'windows-latest'
Py37-Cython-Win:
python.version: '3.7'
no_extensions: ''
image: 'windows-latest'
Py36-Cython-Mac:
python.version: '3.6'
no_extensions: ''
Expand Down
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tests/sample.* binary
tests/data.unknown_mime_type
tests/hello.txt.gz
tests/data.unknown_mime_type binary
tests/hello.txt.gz binary
2 changes: 1 addition & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def url_for(self, *, filename: Union[str, Path], # type: ignore
if filepath.is_file():
# TODO cache file content
# with file watcher for cache invalidation
with open(str(filepath), mode='rb') as f:
with filepath.open('rb') as f:
file_bytes = f.read()
h = self._get_file_hash(file_bytes)
url = url.with_query({self.VERSION_KEY: h})
Expand Down
56 changes: 28 additions & 28 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post(
'/', data={'some': f, 'test': b'data'}, chunked=True)
assert 200 == resp.status
Expand All @@ -1270,7 +1270,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post(
'/',
data={'some': f},
Expand Down Expand Up @@ -1321,8 +1321,8 @@ async def test_POST_FILES_STR(aiohttp_client, fname) -> None:

async def handler(request):
data = await request.post()
with fname.open() as f:
content1 = f.read()
with fname.open('rb') as f:
content1 = f.read().decode()
content2 = data['some']
assert content1 == content2
return web.Response()
Expand All @@ -1331,8 +1331,8 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
resp = await client.post('/', data={'some': f.read()})
with fname.open('rb') as f:
resp = await client.post('/', data={'some': f.read().decode()})
assert 200 == resp.status
resp.close()

Expand All @@ -1350,7 +1350,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post('/', data=f.read())
assert 200 == resp.status
resp.close()
Expand All @@ -1370,7 +1370,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post('/', data=[('some', f)])
assert 200 == resp.status
resp.close()
Expand All @@ -1391,7 +1391,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
form = aiohttp.FormData()
form.add_field('some', f, content_type='text/plain')
resp = await client.post('/', data=form)
Expand All @@ -1403,14 +1403,14 @@ async def test_POST_FILES_SINGLE(aiohttp_client, fname) -> None:

async def handler(request):
data = await request.text()
with fname.open('r') as f:
content = f.read()
with fname.open('rb') as f:
content = f.read().decode()
assert content == data
# if system cannot determine 'application/pgp-keys' MIME type
# then use 'application/octet-stream' default
assert request.content_type in ['application/pgp-keys',
'text/plain',
'application/octet-stream']
# if system cannot determine 'text/x-python' MIME type
# then use 'application/octet-stream' default
assert request.content_type in ['text/plain',
'application/octet-stream',
'text/x-python']
assert 'content-disposition' not in request.headers

return web.Response()
Expand All @@ -1419,7 +1419,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post('/', data=f)
assert 200 == resp.status
resp.close()
Expand All @@ -1430,14 +1430,14 @@ async def test_POST_FILES_SINGLE_content_disposition(

async def handler(request):
data = await request.text()
with fname.open('r') as f:
content = f.read()
with fname.open('rb') as f:
content = f.read().decode()
assert content == data
# if system cannot determine 'application/pgp-keys' MIME type
# then use 'application/octet-stream' default
assert request.content_type in ['application/pgp-keys',
'text/plain',
'application/octet-stream']
# if system cannot determine 'application/pgp-keys' MIME type
# then use 'application/octet-stream' default
assert request.content_type in ['text/plain',
'application/octet-stream',
'text/x-python']
assert request.headers['content-disposition'] == (
"inline; filename=\"conftest.py\"; filename*=utf-8''conftest.py")

Expand All @@ -1447,7 +1447,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post(
'/', data=aiohttp.get_payload(f, disposition='inline'))
assert 200 == resp.status
Expand Down Expand Up @@ -1529,8 +1529,8 @@ async def test_POST_FILES_WITH_DATA(aiohttp_client, fname) -> None:
async def handler(request):
data = await request.post()
assert data['test'] == 'true'
assert data['some'].content_type in ['application/pgp-keys',
'text/plain; charset=utf-8',
assert data['some'].content_type in ['text/x-python',
'text/plain',
'application/octet-stream']
assert data['some'].filename == fname.name
with fname.open('rb') as f:
Expand All @@ -1542,7 +1542,7 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with fname.open() as f:
with fname.open('rb') as f:
resp = await client.post('/', data={'test': 'true', 'some': f})
assert 200 == resp.status
resp.close()
Expand Down
14 changes: 7 additions & 7 deletions tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ async def test_post_single_file(aiohttp_client) -> None:

def check_file(fs):
fullname = here / fs.filename
with fullname.open() as f:
test_data = f.read().encode()
with fullname.open('rb') as f:
test_data = f.read()
data = fs.file.read()
assert test_data == data

Expand All @@ -331,7 +331,7 @@ async def handler(request):

fname = here / 'data.unknown_mime_type'

resp = await client.post('/', data=[fname.open()])
resp = await client.post('/', data=[fname.open('rb')])
assert 200 == resp.status


Expand Down Expand Up @@ -374,8 +374,8 @@ async def test_post_files(aiohttp_client) -> None:

def check_file(fs):
fullname = here / fs.filename
with fullname.open() as f:
test_data = f.read().encode()
with fullname.open('rb') as f:
test_data = f.read()
data = fs.file.read()
assert test_data == data

Expand All @@ -392,8 +392,8 @@ async def handler(request):
app.router.add_post('/', handler)
client = await aiohttp_client(app)

with (here / 'data.unknown_mime_type').open() as f1:
with (here / 'conftest.py').open() as f2:
with (here / 'data.unknown_mime_type').open('rb') as f1:
with (here / 'conftest.py').open('rb') as f2:
resp = await client.post('/', data=[f1, f2])
assert 200 == resp.status

Expand Down
8 changes: 4 additions & 4 deletions tests/test_web_sendfile_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ async def test_static_file_huge(aiohttp_client, tmp_path) -> None:
file_path = tmp_path / 'huge_data.unknown_mime_type'

# fill 20MB file
with file_path.open('w') as f:
with file_path.open('wb') as f:
for i in range(1024*20):
f.write(chr(i % 64 + 0x20) * 1024)
f.write((chr(i % 64 + 0x20) * 1024).encode())

file_st = file_path.stat()

Expand Down Expand Up @@ -754,9 +754,9 @@ async def test_static_file_huge_cancel(aiohttp_client, tmp_path) -> None:
file_path = tmp_path / 'huge_data.unknown_mime_type'

# fill 100MB file
with file_path.open('w') as f:
with file_path.open('wb') as f:
for i in range(1024*20):
f.write(chr(i % 64 + 0x20) * 1024)
f.write((chr(i % 64 + 0x20) * 1024).encode())

task = None

Expand Down

0 comments on commit bbaf125

Please sign in to comment.