Skip to content

Commit dd774e0

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 96025c5 commit dd774e0

File tree

4 files changed

+39
-60
lines changed

4 files changed

+39
-60
lines changed

tests/test_cookiejar.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ async def test_constructor_with_expired(
177177
assert jar._loop is loop
178178

179179

180-
async def test_save_load(
181-
tmp_path, loop, cookies_to_send, cookies_to_receive
182-
) -> None:
180+
async def test_save_load(tmp_path, loop, cookies_to_send, cookies_to_receive) -> None:
183181
file_path = pathlib.Path(str(tmp_path)) / "aiohttp.test.cookie"
184182

185183
# export cookie jar

tests/test_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ def test_parse_mimetype(mimetype, expected) -> None:
7575
def test_guess_filename_with_file_object(tmp_path) -> None:
7676
file_path = tmp_path / "test_guess_filename"
7777
with file_path.open("w+b") as fp:
78-
assert (helpers.guess_filename(fp, "no-throw") is not None)
78+
assert helpers.guess_filename(fp, "no-throw") is not None
7979

8080

8181
def test_guess_filename_with_path(tmp_path) -> None:
8282
file_path = tmp_path / "test_guess_filename"
83-
assert (helpers.guess_filename(file_path, "no-throw") is not None)
83+
assert helpers.guess_filename(file_path, "no-throw") is not None
8484

8585

8686
def test_guess_filename_with_default() -> None:
87-
assert (helpers.guess_filename(None, "no-throw") == "no-throw")
87+
assert helpers.guess_filename(None, "no-throw") == "no-throw"
8888

8989

9090
# ------------------- BasicAuth -----------------------------------

tests/test_urldispatch.py

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -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

343342
def 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

353352
def 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

364361
def 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

376372
def 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

386381
def 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

397390
def 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

405396
def 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

477467
async 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

514503
def 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

520508
def 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

526513
def 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:
789775
def 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

972958
async 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

979964
async 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

995979
def 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

1001984
def 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

11811163
def 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":

tests/test_web_sendfile_functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ async def test_static_file_huge(aiohttp_client, tmp_path) -> None:
563563

564564
# fill 20MB file
565565
with file_path.open("wb") as f:
566-
for i in range(1024*20):
566+
for i in range(1024 * 20):
567567
f.write((chr(i % 64 + 0x20) * 1024).encode())
568568

569569
file_st = file_path.stat()

0 commit comments

Comments
 (0)