Skip to content

Commit

Permalink
rename a shadowed test and re-enable F811 to catch future cases (#8139)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmac committed Feb 8, 2024
1 parent 5df14cf commit 3c0f1eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES/8139.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Two definitions for "test_invalid_route_name" existed, only one was being run. Refactored them into a single parameterized test. Enabled lint rule to prevent regression. -- by :user:`alexmac`.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ zip_ok = false
[flake8]
extend-select = B950
# TODO: don't disable D*, fix up issues instead
ignore = N801,N802,N803,E203,E226,E305,W504,E252,E301,E302,E501,E704,W503,W504,F811,D1,D4
ignore = N801,N802,N803,E203,E226,E305,W504,E252,E301,E302,E501,E704,W503,W504,D1,D4
max-line-length = 88
per-file-ignores =
# I900: Shouldn't appear in requirements for examples.
Expand Down
16 changes: 9 additions & 7 deletions tests/test_urldispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,14 +1146,16 @@ def test_subapp_iter(app: Any) -> None:
assert list(resource) == [r1, r2]


def test_invalid_route_name(router: Any) -> None:
with pytest.raises(ValueError):
router.add_get("/", make_handler(), name="invalid name")


def test_invalid_route_name(router) -> None:
@pytest.mark.parametrize(
"route_name",
(
"invalid name",
"class",
),
)
def test_invalid_route_name(router: Any, route_name: str) -> None:
with pytest.raises(ValueError):
router.add_get("/", make_handler(), name="class") # identifier
router.add_get("/", make_handler(), name=route_name)


def test_frozen_router(router: Any) -> None:
Expand Down

0 comments on commit 3c0f1eb

Please sign in to comment.