From 3b020d080829407d13015a69128ef97851677722 Mon Sep 17 00:00:00 2001 From: Alex Macdonald Date: Tue, 6 Feb 2024 18:06:04 -0800 Subject: [PATCH 1/4] rename an inadvertently shadowed test and re-enable F811 to catch future cases --- setup.cfg | 2 +- tests/test_urldispatch.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index b03fa34235e..f4f768a037d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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. diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index adb1e52e781..a759a2c2e2c 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -1151,7 +1151,7 @@ def test_invalid_route_name(router: Any) -> None: router.add_get("/", make_handler(), name="invalid name") -def test_invalid_route_name(router) -> None: +def test_invalid_route_name_identifier(router) -> None: with pytest.raises(ValueError): router.add_get("/", make_handler(), name="class") # identifier From 1a03c7388f2b23109c72fb6ac9eb2e65746e5395 Mon Sep 17 00:00:00 2001 From: Alex Macdonald Date: Tue, 6 Feb 2024 18:46:34 -0800 Subject: [PATCH 2/4] add file to CHANGES --- CHANGES/8139.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/8139.bugfix.rst diff --git a/CHANGES/8139.bugfix.rst b/CHANGES/8139.bugfix.rst new file mode 100644 index 00000000000..c96bdb4e15d --- /dev/null +++ b/CHANGES/8139.bugfix.rst @@ -0,0 +1 @@ +renamed a shadowed test and re-enabled F811 to catch future cases -- by :user:`alexmac`. From 6e68cfeba3ebc5e9492cd2b501539b9e10717fd5 Mon Sep 17 00:00:00 2001 From: Alex Macdonald Date: Tue, 6 Feb 2024 21:37:07 -0800 Subject: [PATCH 3/4] PR feedback --- CHANGES/8139.bugfix.rst | 1 - CHANGES/8139.contrib.rst | 1 + tests/test_urldispatch.py | 16 +++++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 CHANGES/8139.bugfix.rst create mode 100644 CHANGES/8139.contrib.rst diff --git a/CHANGES/8139.bugfix.rst b/CHANGES/8139.bugfix.rst deleted file mode 100644 index c96bdb4e15d..00000000000 --- a/CHANGES/8139.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -renamed a shadowed test and re-enabled F811 to catch future cases -- by :user:`alexmac`. diff --git a/CHANGES/8139.contrib.rst b/CHANGES/8139.contrib.rst new file mode 100644 index 00000000000..fd743e70f4a --- /dev/null +++ b/CHANGES/8139.contrib.rst @@ -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`. diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index a759a2c2e2c..b94313499a7 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -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_identifier(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: From 4fefdc38c77ace105579ecefd19c5e5e32b522ab Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Wed, 7 Feb 2024 23:19:09 +0000 Subject: [PATCH 4/4] Update tests/test_urldispatch.py --- tests/test_urldispatch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index b94313499a7..9d4ad79ca7b 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -1148,10 +1148,10 @@ def test_subapp_iter(app: Any) -> None: @pytest.mark.parametrize( "route_name", - [ + ( "invalid name", "class", - ], + ), ) def test_invalid_route_name(router: Any, route_name: str) -> None: with pytest.raises(ValueError):