@@ -319,18 +319,18 @@ def test_static_route_path_existence_check() -> None:
319
319
web .StaticResource ("/" , nodirectory )
320
320
321
321
322
- async def test_static_file_huge (aiohttp_client , tmpdir ) -> None :
322
+ async def test_static_file_huge (aiohttp_client , tmp_path ) -> None :
323
323
filename = 'huge_data.unknown_mime_type'
324
324
325
325
# fill 20MB file
326
- with tmpdir . join ( filename ).open ('w' ) as f :
326
+ with ( tmp_path / filename ).open ('w' ) as f :
327
327
for i in range (1024 * 20 ):
328
328
f .write (chr (i % 64 + 0x20 ) * 1024 )
329
329
330
- file_st = os .stat (str (tmpdir . join ( filename )))
330
+ file_st = os .stat (str (( tmp_path / filename )))
331
331
332
332
app = web .Application ()
333
- app .router .add_static ('/static' , str (tmpdir ))
333
+ app .router .add_static ('/static' , str (tmp_path ))
334
334
client = await aiohttp_client (app )
335
335
336
336
resp = await client .get ('/static/' + filename )
@@ -340,7 +340,7 @@ async def test_static_file_huge(aiohttp_client, tmpdir) -> None:
340
340
assert resp .headers .get ('CONTENT-ENCODING' ) is None
341
341
assert int (resp .headers .get ('CONTENT-LENGTH' )) == file_st .st_size
342
342
343
- f = tmpdir . join ( filename ).open ('rb' )
343
+ f = ( tmp_path / filename ).open ('rb' )
344
344
off = 0
345
345
cnt = 0
346
346
while off < file_st .st_size :
@@ -751,11 +751,11 @@ async def handler(request):
751
751
await resp .release ()
752
752
753
753
754
- async def test_static_file_huge_cancel (aiohttp_client , tmpdir ) -> None :
754
+ async def test_static_file_huge_cancel (aiohttp_client , tmp_path ) -> None :
755
755
filename = 'huge_data.unknown_mime_type'
756
756
757
757
# fill 100MB file
758
- with tmpdir . join ( filename ).open ('w' ) as f :
758
+ with ( tmp_path / filename ).open ('w' ) as f :
759
759
for i in range (1024 * 20 ):
760
760
f .write (chr (i % 64 + 0x20 ) * 1024 )
761
761
@@ -768,7 +768,7 @@ async def handler(request):
768
768
tr = request .transport
769
769
sock = tr .get_extra_info ('socket' )
770
770
sock .setsockopt (socket .SOL_SOCKET , socket .SO_SNDBUF , 1024 )
771
- ret = web .FileResponse (pathlib .Path (str (tmpdir . join ( filename ))))
771
+ ret = web .FileResponse (pathlib .Path (str (( tmp_path / filename ))))
772
772
return ret
773
773
774
774
app = web .Application ()
@@ -789,11 +789,11 @@ async def handler(request):
789
789
assert len (data ) < 1024 * 1024 * 20
790
790
791
791
792
- async def test_static_file_huge_error (aiohttp_client , tmpdir ) -> None :
792
+ async def test_static_file_huge_error (aiohttp_client , tmp_path ) -> None :
793
793
filename = 'huge_data.unknown_mime_type'
794
794
795
795
# fill 20MB file
796
- with tmpdir . join ( filename ).open ('wb' ) as f :
796
+ with ( tmp_path / filename ).open ('wb' ) as f :
797
797
f .seek (20 * 1024 * 1024 )
798
798
f .write (b'1' )
799
799
@@ -802,7 +802,7 @@ async def handler(request):
802
802
tr = request .transport
803
803
sock = tr .get_extra_info ('socket' )
804
804
sock .setsockopt (socket .SOL_SOCKET , socket .SO_SNDBUF , 1024 )
805
- ret = web .FileResponse (pathlib .Path (str (tmpdir . join ( filename ))))
805
+ ret = web .FileResponse (pathlib .Path (str (( tmp_path / filename ))))
806
806
return ret
807
807
808
808
app = web .Application ()
0 commit comments