@@ -48,8 +48,7 @@ def fill_routes(router):
4848 def go ():
4949 route1 = router .add_route ("GET" , "/plain" , make_handler ())
5050 route2 = router .add_route ("GET" , "/variable/{name}" , make_handler ())
51- resource = router .add_static ("/static" ,
52- pathlib .Path (aiohttp .__file__ ).parent )
51+ resource = router .add_static ("/static" , pathlib .Path (aiohttp .__file__ ).parent )
5352 return [route1 , route2 ] + list (resource )
5453
5554 return go
@@ -341,19 +340,17 @@ def test_route_dynamic(router) -> None:
341340
342341
343342def test_add_static (router ) -> None :
344- resource = router .add_static ("/st" ,
345- pathlib .Path (aiohttp .__file__ ).parent ,
346- name = "static" )
343+ resource = router .add_static (
344+ "/st" , pathlib .Path (aiohttp .__file__ ).parent , name = "static"
345+ )
347346 assert router ["static" ] is resource
348347 url = resource .url_for (filename = "/dir/a.txt" )
349348 assert "/st/dir/a.txt" == str (url )
350349 assert len (resource ) == 2
351350
352351
353352def test_add_static_append_version (router ) -> None :
354- resource = router .add_static ("/st" ,
355- pathlib .Path (__file__ ).parent ,
356- name = "static" )
353+ resource = router .add_static ("/st" , pathlib .Path (__file__ ).parent , name = "static" )
357354 url = resource .url_for (filename = "/data.unknown_mime_type" , append_version = True )
358355 expect_url = (
359356 "/st/data.unknown_mime_type?" "v=aUsn8CHEhhszc81d28QmlcBW0KQpfS2F4trgQKhOYd8%3D"
@@ -362,10 +359,9 @@ def test_add_static_append_version(router) -> None:
362359
363360
364361def test_add_static_append_version_set_from_constructor (router ) -> None :
365- resource = router .add_static ("/st" ,
366- pathlib .Path (__file__ ).parent ,
367- append_version = True ,
368- name = "static" )
362+ resource = router .add_static (
363+ "/st" , pathlib .Path (__file__ ).parent , append_version = True , name = "static"
364+ )
369365 url = resource .url_for (filename = "/data.unknown_mime_type" )
370366 expect_url = (
371367 "/st/data.unknown_mime_type?" "v=aUsn8CHEhhszc81d28QmlcBW0KQpfS2F4trgQKhOYd8%3D"
@@ -374,19 +370,16 @@ def test_add_static_append_version_set_from_constructor(router) -> None:
374370
375371
376372def test_add_static_append_version_override_constructor (router ) -> None :
377- resource = router .add_static ("/st" ,
378- pathlib .Path (__file__ ).parent ,
379- append_version = True ,
380- name = "static" )
373+ resource = router .add_static (
374+ "/st" , pathlib .Path (__file__ ).parent , append_version = True , name = "static"
375+ )
381376 url = resource .url_for (filename = "/data.unknown_mime_type" , append_version = False )
382377 expect_url = "/st/data.unknown_mime_type"
383378 assert expect_url == str (url )
384379
385380
386381def test_add_static_append_version_filename_without_slash (router ) -> None :
387- resource = router .add_static ("/st" ,
388- pathlib .Path (__file__ ).parent ,
389- name = "static" )
382+ resource = router .add_static ("/st" , pathlib .Path (__file__ ).parent , name = "static" )
390383 url = resource .url_for (filename = "data.unknown_mime_type" , append_version = True )
391384 expect_url = (
392385 "/st/data.unknown_mime_type?" "v=aUsn8CHEhhszc81d28QmlcBW0KQpfS2F4trgQKhOYd8%3D"
@@ -395,17 +388,13 @@ def test_add_static_append_version_filename_without_slash(router) -> None:
395388
396389
397390def test_add_static_append_version_non_exists_file (router ) -> None :
398- resource = router .add_static ("/st" ,
399- pathlib .Path (__file__ ).parent ,
400- name = "static" )
391+ resource = router .add_static ("/st" , pathlib .Path (__file__ ).parent , name = "static" )
401392 url = resource .url_for (filename = "/non_exists_file" , append_version = True )
402393 assert "/st/non_exists_file" == str (url )
403394
404395
405396def test_add_static_append_version_non_exists_file_without_slash (router ) -> None :
406- resource = router .add_static ("/st" ,
407- pathlib .Path (__file__ ).parent ,
408- name = "static" )
397+ resource = router .add_static ("/st" , pathlib .Path (__file__ ).parent , name = "static" )
409398 url = resource .url_for (filename = "non_exists_file" , append_version = True )
410399 assert "/st/non_exists_file" == str (url )
411400
@@ -417,8 +406,9 @@ def test_add_static_append_version_follow_symlink(router, tmp_path) -> None:
417406 pathlib .Path (str (symlink_path )).symlink_to (str (symlink_target_path ), True )
418407
419408 # Register global static route:
420- resource = router .add_static ("/st" , str (tmp_path ), follow_symlinks = True ,
421- append_version = True )
409+ resource = router .add_static (
410+ "/st" , str (tmp_path ), follow_symlinks = True , append_version = True
411+ )
422412
423413 url = resource .url_for (filename = "/append_version_symlink/data.unknown_mime_type" )
424414
@@ -429,17 +419,17 @@ def test_add_static_append_version_follow_symlink(router, tmp_path) -> None:
429419 assert expect_url == str (url )
430420
431421
432- def test_add_static_append_version_not_follow_symlink (router ,
433- tmp_path ) -> None :
422+ def test_add_static_append_version_not_follow_symlink (router , tmp_path ) -> None :
434423 # Tests the access to a symlink, in static folder with apeend_version
435- symlink_path = tmp_path / ' append_version_symlink'
424+ symlink_path = tmp_path / " append_version_symlink"
436425 symlink_target_path = pathlib .Path (__file__ ).parent
437426
438427 pathlib .Path (str (symlink_path )).symlink_to (str (symlink_target_path ), True )
439428
440429 # Register global static route:
441- resource = router .add_static ("/st" , str (tmp_path ), follow_symlinks = False ,
442- append_version = True )
430+ resource = router .add_static (
431+ "/st" , str (tmp_path ), follow_symlinks = False , append_version = True
432+ )
443433
444434 filename = "/append_version_symlink/data.unknown_mime_type"
445435 url = resource .url_for (filename = filename )
@@ -475,8 +465,7 @@ def test_dynamic_not_match(router) -> None:
475465
476466
477467async def test_static_not_match (router ) -> None :
478- router .add_static ("/pre" , pathlib .Path (aiohttp .__file__ ).parent ,
479- name = "name" )
468+ router .add_static ("/pre" , pathlib .Path (aiohttp .__file__ ).parent , name = "name" )
480469 resource = router ["name" ]
481470 ret = await resource .resolve (make_mocked_request ("GET" , "/another/path" ))
482471 assert (None , set ()) == ret
@@ -512,20 +501,17 @@ def test_contains(router) -> None:
512501
513502
514503def test_static_repr (router ) -> None :
515- router .add_static ("/get" , pathlib .Path (aiohttp .__file__ ).parent ,
516- name = "name" )
504+ router .add_static ("/get" , pathlib .Path (aiohttp .__file__ ).parent , name = "name" )
517505 assert Matches (r"<StaticResource 'name' /get" ) == repr (router ["name" ])
518506
519507
520508def test_static_adds_slash (router ) -> None :
521- route = router .add_static ("/prefix" ,
522- pathlib .Path (aiohttp .__file__ ).parent )
509+ route = router .add_static ("/prefix" , pathlib .Path (aiohttp .__file__ ).parent )
523510 assert "/prefix" == route ._prefix
524511
525512
526513def test_static_remove_trailing_slash (router ) -> None :
527- route = router .add_static ("/prefix/" ,
528- pathlib .Path (aiohttp .__file__ ).parent )
514+ route = router .add_static ("/prefix/" , pathlib .Path (aiohttp .__file__ ).parent )
529515 assert "/prefix" == route ._prefix
530516
531517
@@ -789,9 +775,9 @@ def test_named_resources_abc(router) -> None:
789775def test_named_resources (router ) -> None :
790776 route1 = router .add_route ("GET" , "/plain" , make_handler (), name = "route1" )
791777 route2 = router .add_route ("GET" , "/variable/{name}" , make_handler (), name = "route2" )
792- route3 = router .add_static ("/static" ,
793- pathlib .Path (aiohttp .__file__ ).parent ,
794- name = "route3" )
778+ route3 = router .add_static (
779+ "/static" , pathlib .Path (aiohttp .__file__ ).parent , name = "route3"
780+ )
795781 names = {route1 .name , route2 .name , route3 .name }
796782
797783 assert 3 == len (router .named_resources ())
@@ -970,15 +956,13 @@ def test_static_route_points_to_file(router) -> None:
970956
971957
972958async def test_404_for_static_resource (router ) -> None :
973- resource = router .add_static ("/st" ,
974- pathlib .Path (aiohttp .__file__ ).parent )
959+ resource = router .add_static ("/st" , pathlib .Path (aiohttp .__file__ ).parent )
975960 ret = await resource .resolve (make_mocked_request ("GET" , "/unknown/path" ))
976961 assert (None , set ()) == ret
977962
978963
979964async def test_405_for_resource_adapter (router ) -> None :
980- resource = router .add_static ("/st" ,
981- pathlib .Path (aiohttp .__file__ ).parent )
965+ resource = router .add_static ("/st" , pathlib .Path (aiohttp .__file__ ).parent )
982966 ret = await resource .resolve (make_mocked_request ("POST" , "/st/abc.py" ))
983967 assert (None , {"HEAD" , "GET" }) == ret
984968
@@ -993,14 +977,12 @@ async def test_check_allowed_method_for_found_resource(router) -> None:
993977
994978
995979def test_url_for_in_static_resource (router ) -> None :
996- resource = router .add_static ("/static" ,
997- pathlib .Path (aiohttp .__file__ ).parent )
980+ resource = router .add_static ("/static" , pathlib .Path (aiohttp .__file__ ).parent )
998981 assert URL ("/static/file.txt" ) == resource .url_for (filename = "file.txt" )
999982
1000983
1001984def test_url_for_in_static_resource_pathlib (router ) -> None :
1002- resource = router .add_static ("/static" ,
1003- pathlib .Path (aiohttp .__file__ ).parent )
985+ resource = router .add_static ("/static" , pathlib .Path (aiohttp .__file__ ).parent )
1004986 assert URL ("/static/file.txt" ) == resource .url_for (
1005987 filename = pathlib .Path ("file.txt" )
1006988 )
@@ -1179,8 +1161,7 @@ def test_frozen_app_on_subapp(app) -> None:
11791161
11801162
11811163def test_set_options_route (router ) -> None :
1182- resource = router .add_static ("/static" ,
1183- pathlib .Path (aiohttp .__file__ ).parent )
1164+ resource = router .add_static ("/static" , pathlib .Path (aiohttp .__file__ ).parent )
11841165 options = None
11851166 for route in resource :
11861167 if route .method == "OPTIONS" :
0 commit comments