From c39d600aef5c085e891917db04fc97511d2e2259 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 29 Jun 2023 08:05:24 -0700 Subject: [PATCH] Fix all E741 Ambiguous variable name warnings, refs #2090 --- tests/test_plugins.py | 8 +++++--- tests/test_table_html.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 71b710f9..6971bbf7 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -115,7 +115,9 @@ async def test_hook_extra_css_urls(ds_client, path, expected_decoded_object): assert response.status_code == 200 links = Soup(response.text, "html.parser").findAll("link") special_href = [ - l for l in links if l.attrs["href"].endswith("/extra-css-urls-demo.css") + link + for link in links + if link.attrs["href"].endswith("/extra-css-urls-demo.css") ][0]["href"] # This link has a base64-encoded JSON blob in it encoded = special_href.split("/")[3] @@ -543,7 +545,7 @@ async def test_hook_register_output_renderer_can_render(ds_client): .find("p", {"class": "export-links"}) .findAll("a") ) - actual = [l["href"] for l in links] + actual = [link["href"] for link in links] # Should not be present because we sent ?_no_can_render=1 assert "/fixtures/facetable.testall?_labels=on" not in actual # Check that it was passed the values we expected @@ -940,7 +942,7 @@ async def test_hook_table_actions(ds_client, table_or_view): response_2 = await ds_client.get(f"/fixtures/{table_or_view}?_bot=1&_hello=BOB") assert sorted( - get_table_actions_links(response_2.text), key=lambda l: l["label"] + get_table_actions_links(response_2.text), key=lambda link: link["label"] ) == [ {"label": "Database: fixtures", "href": "/"}, {"label": "From async BOB", "href": "/"}, diff --git a/tests/test_table_html.py b/tests/test_table_html.py index e1886dab..c4c7878c 100644 --- a/tests/test_table_html.py +++ b/tests/test_table_html.py @@ -481,7 +481,7 @@ async def test_table_csv_json_export_interface(ds_client): .find("p", {"class": "export-links"}) .findAll("a") ) - actual = [l["href"] for l in links] + actual = [link["href"] for link in links] expected = [ "/fixtures/simple_primary_key.json?id__gt=2", "/fixtures/simple_primary_key.testall?id__gt=2", @@ -521,7 +521,7 @@ async def test_csv_json_export_links_include_labels_if_foreign_keys(ds_client): .find("p", {"class": "export-links"}) .findAll("a") ) - actual = [l["href"] for l in links] + actual = [link["href"] for link in links] expected = [ "/fixtures/facetable.json?_labels=on", "/fixtures/facetable.testall?_labels=on",