From 80d280d451f991f10f57ca78fedac66252eb781c Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Mon, 13 May 2019 11:24:23 +0100 Subject: [PATCH 1/3] Remove @pytest.mark.fuzz This was an unregistered pytest mark, and pytest now emits a warning, which causes our tests to fail, when an unregistered mark is used: https://github.com/pytest-dev/pytest/pull/4935 Rather than registering the mark simply delete all uses of it. All tests that're defined using hypothesis automatically have the `@pytest.mark.hypothesis` mark applied to them so it's not necessary to try to remember to manually apply a custom mark to every test that uses hypothesis: https://hypothesis.readthedocs.io/en/latest/details.html#the-hypothesis-pytest-plugin --- tests/h/auth/tokens_test.py | 1 - tests/h/search/parser_test.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/h/auth/tokens_test.py b/tests/h/auth/tokens_test.py index 1514fb612ba..eb637aa0133 100644 --- a/tests/h/auth/tokens_test.py +++ b/tests/h/auth/tokens_test.py @@ -77,7 +77,6 @@ def test_returns_none_for_malformed_header(self, pyramid_request): assert result is None @given(header=st.text()) - @pytest.mark.fuzz def test_returns_none_for_malformed_header_fuzz(self, header, pyramid_request): assume(not header.startswith("Bearer ")) pyramid_request.headers["Authorization"] = header diff --git a/tests/h/search/parser_test.py b/tests/h/search/parser_test.py index 79fa9f4328a..56c1744a226 100644 --- a/tests/h/search/parser_test.py +++ b/tests/h/search/parser_test.py @@ -128,7 +128,6 @@ def test_parse_with_odd_quotes_combinations(query_in, query_out): @given(st.text()) @settings(max_examples=30) -@pytest.mark.fuzz def test_parse_always_return_a_multidict(text): """Given any string input, output should always be a MultiDict.""" result = parser.parse(text) @@ -144,7 +143,6 @@ def test_parse_always_return_a_multidict(text): @given(kw=st.sampled_from(parser.named_fields), value=nonwhitespace_text) @settings(max_examples=30) -@pytest.mark.fuzz def test_parse_with_any_nonwhitespace_text(kw, value): result = parser.parse(kw + ":" + value) assert result.get(kw) == value From 4bbce1edf9793194838fb2a0a53a11a5fa73b270 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Mon, 13 May 2019 11:39:36 +0100 Subject: [PATCH 2/3] Remove @pytest.mark.functional This is an unregistered custom pytest mark, which causes pytest to omit a warning and fail the tests. There doesn't seem to be any reason to try to manually apply this mark to every single functional test -- these tests are in a separate directory anyway. So rather than registering the mark, delete it. --- tests/functional/api/groups/test_create.py | 1 - tests/functional/api/groups/test_members.py | 2 -- tests/functional/api/groups/test_read.py | 2 -- tests/functional/api/groups/test_update.py | 1 - tests/functional/api/groups/test_upsert.py | 2 -- tests/functional/api/test_annotations.py | 4 ---- tests/functional/api/test_errors.py | 4 ---- tests/functional/api/test_flags.py | 1 - tests/functional/api/test_index.py | 1 - tests/functional/api/test_moderation.py | 2 -- tests/functional/api/test_profile.py | 3 --- tests/functional/api/test_users.py | 2 -- tests/functional/api/test_versions.py | 1 - tests/functional/test_accounts.py | 1 - tests/functional/test_feeds.py | 2 -- tests/functional/test_groups.py | 4 ---- tests/functional/test_moderation.py | 1 - tests/functional/test_oauth.py | 1 - tests/functional/test_search.py | 1 - 19 files changed, 36 deletions(-) diff --git a/tests/functional/api/groups/test_create.py b/tests/functional/api/groups/test_create.py index 32fc0137bd1..b114d8b8113 100644 --- a/tests/functional/api/groups/test_create.py +++ b/tests/functional/api/groups/test_create.py @@ -11,7 +11,6 @@ native_str = str -@pytest.mark.functional class TestCreateGroup(object): def test_it_returns_http_200_with_valid_payload(self, app, token_auth_header): group = {"name": "My Group"} diff --git a/tests/functional/api/groups/test_members.py b/tests/functional/api/groups/test_members.py index 1492a3531fa..f6721b6eb95 100644 --- a/tests/functional/api/groups/test_members.py +++ b/tests/functional/api/groups/test_members.py @@ -11,7 +11,6 @@ native_str = str -@pytest.mark.functional class TestAddMember(object): def test_it_returns_http_204_when_successful( self, app, third_party_user, third_party_group, auth_client_header @@ -146,7 +145,6 @@ def test_it_returns_404_with_token_auth(self, app, token_auth_header, user, grou assert res.status_code == 404 -@pytest.mark.functional class TestRemoveMember(object): def test_it_removes_authed_user_from_group( self, app, group, group_member_with_token diff --git a/tests/functional/api/groups/test_read.py b/tests/functional/api/groups/test_read.py index 6ad0edfd211..6761a185f54 100644 --- a/tests/functional/api/groups/test_read.py +++ b/tests/functional/api/groups/test_read.py @@ -11,7 +11,6 @@ native_str = str -@pytest.mark.functional class TestReadGroups(object): # TODO: In subsequent versions of the API, this should really be a group # search endpoint and should have its own functional test module @@ -59,7 +58,6 @@ def test_it_expands_scope_if_requested(self, app): assert "scopes" in res.json[0] -@pytest.mark.functional class TestReadGroup(object): def test_it_returns_http_200_for_world_readable_group_pubid( self, app, factories, db_session diff --git a/tests/functional/api/groups/test_update.py b/tests/functional/api/groups/test_update.py index d3b4044f013..7fcb03d2705 100644 --- a/tests/functional/api/groups/test_update.py +++ b/tests/functional/api/groups/test_update.py @@ -10,7 +10,6 @@ native_str = str -@pytest.mark.functional class TestUpdateGroup(object): def test_it_returns_http_200_with_valid_payload_and_user_token( self, app, token_auth_header, first_party_group diff --git a/tests/functional/api/groups/test_upsert.py b/tests/functional/api/groups/test_upsert.py index a07bd37417d..a12600b565d 100644 --- a/tests/functional/api/groups/test_upsert.py +++ b/tests/functional/api/groups/test_upsert.py @@ -10,7 +10,6 @@ native_str = str -@pytest.mark.functional class TestUpsertGroupUpdate(object): def test_it_returns_http_404_if_no_authenticated_user(self, app, first_party_group): group = {"name": "My Group"} @@ -210,7 +209,6 @@ def test_it_returns_HTTP_Conflict_if_groupid_is_duplicate( assert res.status_code == 409 -@pytest.mark.functional class TestUpsertGroupCreate(object): def test_it_allows_auth_client_with_forwarded_user( self, app, auth_client_header, third_party_user diff --git a/tests/functional/api/test_annotations.py b/tests/functional/api/test_annotations.py index 416cff28b48..3e93ba3544b 100644 --- a/tests/functional/api/test_annotations.py +++ b/tests/functional/api/test_annotations.py @@ -13,7 +13,6 @@ native_str = str -@pytest.mark.functional class TestGetAnnotation(object): def test_it_returns_annotation_if_shared(self, app, annotation): """Unauthenticated users may view shared annotations assuming they have group access""" @@ -50,7 +49,6 @@ def test_it_returns_http_404_for_private_annotation_when_unauthorized( assert res.status_code == 404 -@pytest.mark.functional class TestGetAnnotationJSONLD(object): def test_it_returns_annotation_if_shared(self, app, annotation): """Unauthenticated users may view shared annotations assuming they have group access""" @@ -159,7 +157,6 @@ def test_it_returns_http_200_when_annotation_created(self, app, user_with_token) assert res.status_code == 200 -@pytest.mark.functional class TestPatchAnnotation(object): def test_it_updates_annotation_if_authorized( self, app, user_annotation, user_with_token @@ -211,7 +208,6 @@ def test_it_returns_http_404_if_unauthorized( assert res.status_code == 404 -@pytest.mark.functional class TestDeleteAnnotation(object): def test_it_deletes_annotation_if_authorized( self, app, user_annotation, user_with_token diff --git a/tests/functional/api/test_errors.py b/tests/functional/api/test_errors.py index 05bdd6b7f58..1b9ea034074 100644 --- a/tests/functional/api/test_errors.py +++ b/tests/functional/api/test_errors.py @@ -17,7 +17,6 @@ native_str = str -@pytest.mark.functional class Test400Errors(object): """Creating a group can raise all of the client errors we want to test""" @@ -44,7 +43,6 @@ def test_it_400s_for_create_group_if_groupid_set_on_default_authority( assert stripped == expected -@pytest.mark.functional class Test404Errors(object): # TODO: Some of these 404s should really be 403s def test_it_404s_if_authz_fail_with_valid_accept(self, app, append_auth_client): @@ -94,7 +92,6 @@ def test_it_404s_if_not_found_with_missing_accept_and_no_authz(self, app): ) -@pytest.mark.functional class Test409Errors(object): def test_it_409s_on_create_group_if_groupid_is_duplicate( self, app, append_auth_client, third_party_user @@ -113,7 +110,6 @@ def test_it_409s_on_create_group_if_groupid_is_duplicate( ) -@pytest.mark.functional class Test415Errors(object): def test_it_415s_if_not_found_with_bad_accept(self, app): headers = {} diff --git a/tests/functional/api/test_flags.py b/tests/functional/api/test_flags.py index 81d784aee3e..57a4028c3b5 100644 --- a/tests/functional/api/test_flags.py +++ b/tests/functional/api/test_flags.py @@ -13,7 +13,6 @@ native_str = str -@pytest.mark.functional class TestPutFlag(object): def test_it_returns_http_204_if_user_allowed_to_flag_shared_annotation( self, app, annotation, user_with_token diff --git a/tests/functional/api/test_index.py b/tests/functional/api/test_index.py index b31724d361d..33afb248714 100644 --- a/tests/functional/api/test_index.py +++ b/tests/functional/api/test_index.py @@ -13,7 +13,6 @@ native_str = str -@pytest.mark.functional class TestGetIndex(object): def test_it_returns_links(self, app): res = app.get("/api/") diff --git a/tests/functional/api/test_moderation.py b/tests/functional/api/test_moderation.py index 06ace9e751c..3d4c7eee290 100644 --- a/tests/functional/api/test_moderation.py +++ b/tests/functional/api/test_moderation.py @@ -13,7 +13,6 @@ native_str = str -@pytest.mark.functional class TestPutHide(object): def test_it_returns_http_204_for_group_creator( self, app, group_annotation, user_with_token @@ -67,7 +66,6 @@ def test_it_returns_http_404_if_annotation_is_private( assert res.status_code == 404 -@pytest.mark.functional class TestDeleteHide(object): def test_it_returns_http_204_for_group_creator( self, app, group_annotation, user_with_token diff --git a/tests/functional/api/test_profile.py b/tests/functional/api/test_profile.py index 77b54e2b447..b7f1f3996b9 100644 --- a/tests/functional/api/test_profile.py +++ b/tests/functional/api/test_profile.py @@ -13,7 +13,6 @@ native_str = str -@pytest.mark.functional class TestGetProfile(object): def test_it_returns_profile_with_single_group_when_not_authd(self, app): """ @@ -58,7 +57,6 @@ def test_it_returns_profile_for_third_party_authd_user( assert group_ids == [] -@pytest.mark.functional class TestGetProfileGroups(object): def test_it_returns_empty_list_when_not_authed(self, app): res = app.get("/api/profile/groups") @@ -88,7 +86,6 @@ def test_it_returns_group_properties(self, app, user_with_token): assert property in res.json[0] -@pytest.mark.functional class TestPatchProfile(object): def test_it_allows_authenticated_user(self, app, user_with_token): """PATCH profile will always act on the auth'd user's profile.""" diff --git a/tests/functional/api/test_users.py b/tests/functional/api/test_users.py index f3659da4ffb..03fcbf83e01 100644 --- a/tests/functional/api/test_users.py +++ b/tests/functional/api/test_users.py @@ -17,7 +17,6 @@ native_str = str -@pytest.mark.functional class TestCreateUser(object): def test_it_returns_http_200_when_successful( self, app, auth_client_header, user_payload @@ -86,7 +85,6 @@ def test_it_returns_409_if_user_conflict( assert res.status_code == 409 -@pytest.mark.functional class TestUpdateUser(object): def test_it_returns_http_200_when_successful( self, app, auth_client_header, user, patch_user_payload diff --git a/tests/functional/api/test_versions.py b/tests/functional/api/test_versions.py index 4806787264d..23f8d5f97d4 100644 --- a/tests/functional/api/test_versions.py +++ b/tests/functional/api/test_versions.py @@ -16,7 +16,6 @@ native_str = str -@pytest.mark.functional class TestIndexEndpointVersions(object): def test_index_sets_version_response_header(self, app): """ diff --git a/tests/functional/test_accounts.py b/tests/functional/test_accounts.py index 9fec6767b4b..1e96eaf2df3 100644 --- a/tests/functional/test_accounts.py +++ b/tests/functional/test_accounts.py @@ -5,7 +5,6 @@ import pytest -@pytest.mark.functional class TestAccountSettings(object): """Tests for the /account/settings page.""" diff --git a/tests/functional/test_feeds.py b/tests/functional/test_feeds.py index 28b5e2ab74b..56b83bbeeeb 100644 --- a/tests/functional/test_feeds.py +++ b/tests/functional/test_feeds.py @@ -5,11 +5,9 @@ import pytest -@pytest.mark.functional def test_atom_feed(app): app.get("/stream.atom") -@pytest.mark.functional def test_rss_feed(app): app.get("/stream.rss") diff --git a/tests/functional/test_groups.py b/tests/functional/test_groups.py index fe43ac8a9d5..c34953da9eb 100644 --- a/tests/functional/test_groups.py +++ b/tests/functional/test_groups.py @@ -6,7 +6,6 @@ @pytest.mark.xfail # See https://github.com/hypothesis/product-backlog/issues/109 -@pytest.mark.functional def test_group_page_includes_referrer_tag(app, db_session, factories, user): """ The group read page should include a referrer tag. @@ -27,7 +26,6 @@ def test_group_page_includes_referrer_tag(app, db_session, factories, user): assert res.html.head.find("meta", attrs={"name": "referrer"}, content="origin") -@pytest.mark.functional def test_submit_create_group_form_without_xhr_returns_full_html_page(app): res = app.get("/groups/new") group_form = res.forms["deform"] @@ -38,7 +36,6 @@ def test_submit_create_group_form_without_xhr_returns_full_html_page(app): assert res.text.startswith("") -@pytest.mark.functional def test_submit_create_group_form_with_xhr_returns_partial_html_snippet(app): res = app.get("/groups/new") group_form = res.forms["deform"] @@ -49,7 +46,6 @@ def test_submit_create_group_form_with_xhr_returns_partial_html_snippet(app): assert res.body.strip(b"\n").startswith(b" Date: Mon, 13 May 2019 11:58:30 +0100 Subject: [PATCH 3/3] Lint --- tests/functional/api/test_versions.py | 2 -- tests/functional/test_feeds.py | 2 -- tests/functional/test_search.py | 2 -- tests/h/auth/tokens_test.py | 1 - 4 files changed, 7 deletions(-) diff --git a/tests/functional/api/test_versions.py b/tests/functional/api/test_versions.py index 23f8d5f97d4..3639b61097c 100644 --- a/tests/functional/api/test_versions.py +++ b/tests/functional/api/test_versions.py @@ -5,8 +5,6 @@ from __future__ import unicode_literals -import pytest - # String type for request/response headers and metadata in WSGI. # # Per PEP-3333, this is intentionally `str` under both Python 2 and 3, even diff --git a/tests/functional/test_feeds.py b/tests/functional/test_feeds.py index 56b83bbeeeb..96fab3d650f 100644 --- a/tests/functional/test_feeds.py +++ b/tests/functional/test_feeds.py @@ -2,8 +2,6 @@ from __future__ import unicode_literals -import pytest - def test_atom_feed(app): app.get("/stream.atom") diff --git a/tests/functional/test_search.py b/tests/functional/test_search.py index ec32bf8551a..857bc6f77b8 100644 --- a/tests/functional/test_search.py +++ b/tests/functional/test_search.py @@ -3,8 +3,6 @@ from __future__ import unicode_literals -import pytest - def test_search_input_text_is_submitted_as_q_without_javascript(app): res = app.get("/search") diff --git a/tests/h/auth/tokens_test.py b/tests/h/auth/tokens_test.py index eb637aa0133..210627e92ad 100644 --- a/tests/h/auth/tokens_test.py +++ b/tests/h/auth/tokens_test.py @@ -6,7 +6,6 @@ import jwt import mock -import pytest from hypothesis import strategies as st from hypothesis import assume, given