From b59b92b1b0517cf18fa748ff9d0a0bf86298dd43 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 18 Jun 2020 16:52:06 -0700 Subject: [PATCH] Fix for tests - order was inconsistent, refs #852 --- tests/test_canned_write.py | 20 ++++++++++++-------- tests/test_html.py | 8 +++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/test_canned_write.py b/tests/test_canned_write.py index c36baa09da..e33eed6951 100644 --- a/tests/test_canned_write.py +++ b/tests/test_canned_write.py @@ -108,16 +108,16 @@ def test_vary_header(canned_write_client): def test_canned_query_permissions_on_database_page(canned_write_client): # Without auth only shows three queries - query_names = [ + query_names = { q["name"] for q in canned_write_client.get("/data.json").json["queries"] - ] - assert [ + } + assert { "add_name", "add_name_specify_id", "update_name", "from_async_hook", "from_hook", - ] == query_names + } == query_names # With auth shows four response = canned_write_client.get( @@ -129,12 +129,16 @@ def test_canned_query_permissions_on_database_page(canned_write_client): {"name": "add_name", "private": False}, {"name": "add_name_specify_id", "private": False}, {"name": "delete_name", "private": True}, - {"name": "update_name", "private": False}, {"name": "from_async_hook", "private": False}, {"name": "from_hook", "private": False}, - ] == [ - {"name": q["name"], "private": q["private"]} for q in response.json["queries"] - ] + {"name": "update_name", "private": False}, + ] == sorted( + [ + {"name": q["name"], "private": q["private"]} + for q in response.json["queries"] + ], + key=lambda q: q["name"], + ) def test_canned_query_permissions(canned_write_client): diff --git a/tests/test_html.py b/tests/test_html.py index 7bc935b08e..1c7dce9041 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -95,11 +95,13 @@ def test_database_page(app_client): "/fixtures/%F0%9D%90%9C%F0%9D%90%A2%F0%9D%90%AD%F0%9D%90%A2%F0%9D%90%9E%F0%9D%90%AC", "𝐜𝐢𝐭𝐢𝐞𝐬", ), - ("/fixtures/pragma_cache_size", "pragma_cache_size"), - ("/fixtures/neighborhood_search#fragment-goes-here", "Search neighborhoods"), ("/fixtures/from_async_hook", "from_async_hook"), ("/fixtures/from_hook", "from_hook"), - ] == [(a["href"], a.text) for a in queries_ul.find_all("a")] + ("/fixtures/neighborhood_search#fragment-goes-here", "Search neighborhoods"), + ("/fixtures/pragma_cache_size", "pragma_cache_size"), + ] == sorted( + [(a["href"], a.text) for a in queries_ul.find_all("a")], key=lambda p: p[0] + ) def test_invalid_custom_sql(app_client):