Skip to content

Commit

Permalink
[3.6] Enable windows CI (#4176). (#4183)
Browse files Browse the repository at this point in the history
(cherry picked from commit bbaf125)

Co-authored-by: Andrew Svetlov <[email protected]>
  • Loading branch information
asvetlov authored Oct 14, 2019
1 parent 9cee65f commit d0eabc2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
24 changes: 12 additions & 12 deletions .azure-pipelines/stage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ stages:
# python.version: 'pypy3'
# no_extensions: 'Y'
# image: 'ubuntu-latest'
# Py35-Cython-Win:
# python.version: '3.5'
# 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'
Py35-Cython-Win:
python.version: '3.5'
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'
Py35-Cython-Mac:
python.version: '3.5'
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 @@ -553,7 +553,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 @@ -1251,7 +1251,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 @@ -1273,7 +1273,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 @@ -1324,8 +1324,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 @@ -1334,8 +1334,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 @@ -1353,7 +1353,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 @@ -1373,7 +1373,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 @@ -1394,7 +1394,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 @@ -1406,14 +1406,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 @@ -1422,7 +1422,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 @@ -1433,14 +1433,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 @@ -1450,7 +1450,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 @@ -1532,8 +1532,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 @@ -1545,7 +1545,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 @@ -312,8 +312,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 @@ -332,7 +332,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 @@ -375,8 +375,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 @@ -393,8 +393,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 @@ -323,9 +323,9 @@ async def test_static_file_huge(aiohttp_client, tmpdir) -> None:
filename = 'huge_data.unknown_mime_type'

# fill 20MB file
with tmpdir.join(filename).open('w') as f:
with tmpdir.join(filename).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 = os.stat(str(tmpdir.join(filename)))

Expand Down Expand Up @@ -755,9 +755,9 @@ async def test_static_file_huge_cancel(aiohttp_client, tmpdir) -> None:
filename = 'huge_data.unknown_mime_type'

# fill 100MB file
with tmpdir.join(filename).open('w') as f:
with tmpdir.join(filename).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 d0eabc2

Please sign in to comment.