From aafa7178f96e461f936e0e8807f8ba3257e08dab Mon Sep 17 00:00:00 2001
From: Carlo Costino inset text inset textinset text
inset text
"], - [ + ("markdown_function", "expected"), + [ + (notify_letter_preview_markdown, "inset text
"), + ( notify_email_markdown, 'inset text
', - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n" "\ninset text"), - ], - ), + ), + ], ) def test_level_2_header(markdown_function, expected): assert markdown_function("## inset text") == (expected) @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_letter_preview_markdown, ("a
" 'b
"), - ], - [ + ), + ( notify_email_markdown, ( 'a
' 'b
' ), - ], - [ + ), + ( notify_plain_text_email_markdown, ( "\n" @@ -268,8 +268,8 @@ def test_level_2_header(markdown_function, expected): "\n" "\nb" ), - ], - ), + ), + ], ) def test_hrule(markdown_function, expected): assert markdown_function("a\n\n***\n\nb") == expected @@ -277,13 +277,13 @@ def test_hrule(markdown_function, expected): @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_letter_preview_markdown, ("+ one
+ two
+ three
", - ], - [ + ), + ( notify_email_markdown, ( '+ one
' '+ two
' '+ three
' ), - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n\n+ one" "\n\n+ two" "\n\n+ three"), - ], - ), + ), + ], ) def test_pluses_dont_render_as_lists(markdown_function, expected): assert markdown_function("+ one\n" "+ two\n" "+ three\n") == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_letter_preview_markdown, ("" "line one
" "line two" "
" "new paragraph" "
"), - ], - [ + ), + ( notify_email_markdown, ( 'line one
'
"line two
new paragraph
' ), - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n" "\nline one" "\nline two" "\n" "\nnew paragraph"), - ], - ), + ), + ], ) def test_paragraphs(markdown_function, expected): assert markdown_function("line one\n" "line two\n" "\n" "new paragraph") == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [notify_letter_preview_markdown, ("before
" "after
")], - [ + ("markdown_function", "expected"), + [ + (notify_letter_preview_markdown, ("before
" "after
")), + ( notify_email_markdown, ( 'before
' 'after
' ), - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n" "\nbefore" "\n" "\nafter"), - ], - ), + ), + ], ) def test_multiple_newlines_get_truncated(markdown_function, expected): assert markdown_function("before\n\n\n\n\n\nafter") == expected @@ -437,25 +436,25 @@ def test_multiple_newlines_get_truncated(markdown_function, expected): @pytest.mark.parametrize( "markdown_function", - ( + [ notify_letter_preview_markdown, notify_email_markdown, notify_plain_text_email_markdown, - ), + ], ) def test_table(markdown_function): assert markdown_function("col | col\n" "----|----\n" "val | val\n") == ("") @pytest.mark.parametrize( - "markdown_function, link, expected", - ( - [ + ("markdown_function", "link", "expected"), + [ + ( notify_letter_preview_markdown, "http://example.com", "example.com
", - ], - [ + ), + ( notify_email_markdown, "http://example.com", ( @@ -463,8 +462,8 @@ def test_table(markdown_function): 'http://example.com' "" ), - ], - [ + ), + ( notify_email_markdown, """https://example.com"onclick="alert('hi')""", ( @@ -475,105 +474,105 @@ def test_table(markdown_function): "')" "" ), - ], - [ + ), + ( notify_plain_text_email_markdown, "http://example.com", ("\n" "\nhttp://example.com"), - ], - ), + ), + ], ) def test_autolink(markdown_function, link, expected): assert markdown_function(link) == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [notify_letter_preview_markdown, "variable called `thing`
"], - [ + ("markdown_function", "expected"), + [ + (notify_letter_preview_markdown, "variable called `thing`
"), + ( notify_email_markdown, 'variable called `thing`
', # noqa E501 - ], - [ + ), + ( notify_plain_text_email_markdown, "\n\nvariable called `thing`", - ], - ), + ), + ], ) def test_codespan(markdown_function, expected): assert markdown_function("variable called `thing`") == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [notify_letter_preview_markdown, "something **important**
"], - [ + ("markdown_function", "expected"), + [ + (notify_letter_preview_markdown, "something **important**
"), + ( notify_email_markdown, 'something **important**
', # noqa E501 - ], - [ + ), + ( notify_plain_text_email_markdown, "\n\nsomething **important**", - ], - ), + ), + ], ) def test_double_emphasis(markdown_function, expected): assert markdown_function("something **important**") == expected @pytest.mark.parametrize( - "markdown_function, text, expected", - ( - [ + ("markdown_function", "text", "expected"), + [ + ( notify_letter_preview_markdown, "something *important*", "something *important*
", - ], - [ + ), + ( notify_email_markdown, "something *important*", 'something *important*
', # noqa E501 - ], - [ + ), + ( notify_plain_text_email_markdown, "something *important*", "\n\nsomething *important*", - ], - [ + ), + ( notify_plain_text_email_markdown, "something _important_", "\n\nsomething _important_", - ], - [ + ), + ( notify_plain_text_email_markdown, "before*after", "\n\nbefore*after", - ], - [ + ), + ( notify_plain_text_email_markdown, "before_after", "\n\nbefore_after", - ], - ), + ), + ], ) def test_emphasis(markdown_function, text, expected): assert markdown_function(text) == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_email_markdown, 'foo ****** bar
', - ], - [ + ), + ( notify_plain_text_email_markdown, "\n\nfoo ****** bar", - ], - ), + ), + ], ) def test_nested_emphasis(markdown_function, expected): assert markdown_function("foo ****** bar") == expected @@ -581,24 +580,24 @@ def test_nested_emphasis(markdown_function, expected): @pytest.mark.parametrize( "markdown_function", - ( + [ notify_letter_preview_markdown, notify_email_markdown, notify_plain_text_email_markdown, - ), + ], ) def test_image(markdown_function): assert markdown_function("") == ("") @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_letter_preview_markdown, ("Example: example.com
"), - ], - [ + ), + ( notify_email_markdown, ( 'Example' "
" ), - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n" "\nExample: http://example.com"), - ], - ), + ), + ], ) def test_link(markdown_function, expected): assert markdown_function("[Example](http://example.com)") == expected @pytest.mark.parametrize( - "markdown_function, expected", - ( - [ + ("markdown_function", "expected"), + [ + ( notify_letter_preview_markdown, ("Example: example.com
"), - ], - [ + ), + ( notify_email_markdown, ( '" "
" ), - ], - [ + ), + ( notify_plain_text_email_markdown, ("\n" "\nExample (An example URL): http://example.com"), - ], - ), + ), + ], ) def test_link_with_title(markdown_function, expected): assert ( @@ -648,15 +647,15 @@ def test_link_with_title(markdown_function, expected): @pytest.mark.parametrize( - "markdown_function, expected", - ( - [notify_letter_preview_markdown, "~~Strike~~
"], - [ + ("markdown_function", "expected"), + [ + (notify_letter_preview_markdown, "~~Strike~~
"), + ( notify_email_markdown, '~~Strike~~
', - ], - [notify_plain_text_email_markdown, "\n\n~~Strike~~"], - ), + ), + (notify_plain_text_email_markdown, "\n\n~~Strike~~"), + ], ) def test_strikethrough(markdown_function, expected): assert markdown_function("~~Strike~~") == expected diff --git a/tests/notifications_utils/test_placeholders.py b/tests/notifications_utils/test_placeholders.py index 7ac11c3c9..348d2159a 100644 --- a/tests/notifications_utils/test_placeholders.py +++ b/tests/notifications_utils/test_placeholders.py @@ -6,7 +6,7 @@ from notifications_utils.field import Placeholder @pytest.mark.parametrize( - "body, expected", + ("body", "expected"), [ ("((with-brackets))", "with-brackets"), ("without-brackets", "without-brackets"), @@ -17,7 +17,7 @@ def test_placeholder_returns_name(body, expected): @pytest.mark.parametrize( - "body, is_conditional", + ("body", "is_conditional"), [ ("not a conditional", False), ("not? a conditional", False), @@ -29,7 +29,7 @@ def test_placeholder_identifies_conditional(body, is_conditional): @pytest.mark.parametrize( - "body, conditional_text", + ("body", "conditional_text"), [ ("a??b", "b"), ("a?? b ", " b "), @@ -41,12 +41,12 @@ def test_placeholder_gets_conditional_text(body, conditional_text): def test_placeholder_raises_if_accessing_conditional_text_on_non_conditional(): - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa, flake8 says ValueError not specific enough Placeholder("hello").conditional_text @pytest.mark.parametrize( - "body, value, result", + ("body", "value", "result"), [ ("a??b", "Yes", "b"), ("a??b", "No", ""), @@ -57,7 +57,7 @@ def test_placeholder_gets_conditional_body(body, value, result): def test_placeholder_raises_if_getting_conditional_body_on_non_conditional(): - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa, flake8 says ValueError not specific enough Placeholder("hello").get_conditional_body("Yes") diff --git a/tests/notifications_utils/test_postal_address.py b/tests/notifications_utils/test_postal_address.py index f854944cd..3e29f193f 100644 --- a/tests/notifications_utils/test_postal_address.py +++ b/tests/notifications_utils/test_postal_address.py @@ -17,8 +17,8 @@ def test_raw_address(): @pytest.mark.parametrize( - "address, expected_country", - ( + ("address", "expected_country"), + [ ( """ 123 Example Street @@ -51,15 +51,15 @@ def test_raw_address(): """, Country("Germany"), ), - ), + ], ) def test_country(address, expected_country): assert PostalAddress(address).country == expected_country @pytest.mark.parametrize( - "address, enough_lines_expected", - ( + ("address", "enough_lines_expected"), + [ ( "", False, @@ -102,15 +102,15 @@ def test_country(address, expected_country): """, True, ), - ), + ], ) def test_has_enough_lines(address, enough_lines_expected): assert PostalAddress(address).has_enough_lines is enough_lines_expected @pytest.mark.parametrize( - "address, too_many_lines_expected", - ( + ("address", "too_many_lines_expected"), + [ ( "", False, @@ -171,15 +171,15 @@ def test_has_enough_lines(address, enough_lines_expected): """, True, ), - ), + ], ) def test_has_too_many_lines(address, too_many_lines_expected): assert PostalAddress(address).has_too_many_lines is too_many_lines_expected @pytest.mark.parametrize( - "address, expected_postcode", - ( + ("address", "expected_postcode"), + [ ( "", None, @@ -215,7 +215,7 @@ def test_has_too_many_lines(address, too_many_lines_expected): """, None, ), - ), + ], ) def test_postcode(address, expected_postcode): assert PostalAddress(address).has_valid_postcode is bool(expected_postcode) @@ -223,7 +223,7 @@ def test_postcode(address, expected_postcode): @pytest.mark.parametrize( - "address, expected_result", + ("address", "expected_result"), [ ( "", @@ -276,8 +276,8 @@ def test_has_invalid_characters(address, expected_result): @pytest.mark.parametrize( - "address, expected_international", - ( + ("address", "expected_international"), + [ ( "", False, @@ -313,15 +313,15 @@ def test_has_invalid_characters(address, expected_result): """, True, ), - ), + ], ) def test_international(address, expected_international): assert PostalAddress(address).international is expected_international @pytest.mark.parametrize( - "address, expected_normalised, expected_as_single_line", - ( + ("address", "expected_normalised", "expected_as_single_line"), + [ ( "", "", @@ -357,7 +357,7 @@ def test_international(address, expected_international): ("123 Example Straße\n" "Germany"), ("123 Example Straße, Germany"), ), - ), + ], ) def test_normalised(address, expected_normalised, expected_as_single_line): assert PostalAddress(address).normalised == expected_normalised @@ -365,8 +365,8 @@ def test_normalised(address, expected_normalised, expected_as_single_line): @pytest.mark.parametrize( - "address, expected_postage", - ( + ("address", "expected_postage"), + [ ( "", Postage.UK, @@ -401,7 +401,7 @@ def test_normalised(address, expected_normalised, expected_as_single_line): """, Postage.REST_OF_WORLD, ), - ), + ], ) def test_postage(address, expected_postage): assert PostalAddress(address).postage == expected_postage @@ -409,7 +409,7 @@ def test_postage(address, expected_postage): @pytest.mark.parametrize( "personalisation", - ( + [ { "address_line_1": "123 Example Street", "address_line_3": "City of Town", @@ -440,7 +440,7 @@ def test_postage(address, expected_postage): "Address-Line-7": "Sw1a 1aa", } ), - ), + ], ) def test_from_personalisation(personalisation): assert PostalAddress.from_personalisation(personalisation).normalised == ( @@ -461,8 +461,8 @@ def test_from_personalisation_handles_int(): @pytest.mark.parametrize( - "address, expected_personalisation", - ( + ("address", "expected_personalisation"), + [ ( "", { @@ -515,27 +515,27 @@ def test_from_personalisation_handles_int(): "postcode": "Eight", }, ), - ), + ], ) def test_as_personalisation(address, expected_personalisation): assert PostalAddress(address).as_personalisation == expected_personalisation @pytest.mark.parametrize( - "address, expected_bool", - ( + ("address", "expected_bool"), + [ ("", False), (" ", False), ("\n\n \n", False), ("a", True), - ), + ], ) def test_bool(address, expected_bool): assert bool(PostalAddress(address)) is expected_bool @pytest.mark.parametrize( - "postcode, normalised_postcode", + ("postcode", "normalised_postcode"), [ ("SW1 3EF", "SW13EF"), ("SW13EF", "SW13EF"), @@ -550,7 +550,7 @@ def test_normalise_postcode(postcode, normalised_postcode): @pytest.mark.parametrize( - "postcode, result", + ("postcode", "result"), [ # real standard UK poscodes ("SW1 3EF", True), @@ -592,7 +592,7 @@ def test_if_postcode_is_a_real_uk_postcode_normalises_before_checking_postcode(m @pytest.mark.parametrize( - "postcode, postcode_with_space", + ("postcode", "postcode_with_space"), [ ("SW13EF", "SW1 3EF"), ("SW1 3EF", "SW1 3EF"), @@ -615,8 +615,8 @@ def test_format_postcode_for_printing(postcode, postcode_with_space): @pytest.mark.parametrize( - "address, international, expected_valid", - ( + ("address", "international", "expected_valid"), + [ ( """ UK address @@ -703,7 +703,7 @@ def test_format_postcode_for_printing(postcode, postcode_with_space): False, False, ), - ), + ], ) def test_valid_with_international_parameter(address, international, expected_valid): postal_address = PostalAddress( @@ -716,7 +716,7 @@ def test_valid_with_international_parameter(address, international, expected_val @pytest.mark.parametrize( "address", - ( + [ """ Too short, valid postcode SW1A 1AA @@ -745,7 +745,7 @@ def test_valid_with_international_parameter(address, international, expected_val 7 Bhutan """, - ), + ], ) def test_valid_last_line_too_short_too_long(address): postal_address = PostalAddress(address, allow_international_letters=True) @@ -759,11 +759,11 @@ def test_valid_with_invalid_characters(): @pytest.mark.parametrize( - "international, expected_valid", - ( + ("international", "expected_valid"), + [ (False, False), (True, True), - ), + ], ) def test_valid_from_personalisation_with_international_parameter( international, expected_valid diff --git a/tests/notifications_utils/test_recipient_csv.py b/tests/notifications_utils/test_recipient_csv.py index e11bb14ad..689781f6a 100644 --- a/tests/notifications_utils/test_recipient_csv.py +++ b/tests/notifications_utils/test_recipient_csv.py @@ -43,8 +43,8 @@ def _index_rows(rows): @pytest.mark.parametrize( - "template_type, expected", - ( + ("template_type", "expected"), + [ ("email", ["email address"]), ("sms", ["phone number"]), ( @@ -60,7 +60,7 @@ def _index_rows(rows): "address line 7", ], ), - ), + ], ) def test_recipient_column_headers(template_type, expected): recipients = RecipientCSV("", template=_sample_template(template_type)) @@ -72,7 +72,7 @@ def test_recipient_column_headers(template_type, expected): @pytest.mark.parametrize( - "file_contents,template_type,expected", + ("file_contents", "template_type", "expected"), [ ( "", @@ -275,7 +275,7 @@ def test_get_rows_only_iterates_over_file_once(mocker): @pytest.mark.parametrize( - "file_contents,template_type,expected", + ("file_contents", "template_type", "expected"), [ ( """ @@ -341,7 +341,7 @@ def test_get_rows_with_errors(): @pytest.mark.parametrize( - "template_type, row_count, header, filler, row_with_error", + ("template_type", "row_count", "header", "filler", "row_with_error"), [ ( "email", @@ -370,7 +370,7 @@ def test_big_list_validates_right_through( @pytest.mark.parametrize( - "template_type, row_count, header, filler", + ("template_type", "row_count", "header", "filler"), [ ("email", 50, "email address\n", "test@example.com\n"), ("sms", 50, "phone number\n", "07900900123\n"), @@ -456,7 +456,7 @@ def test_empty_column_names(): @pytest.mark.parametrize( - "file_contents,template,expected_recipients,expected_personalisation", + ("file_contents", "template", "expected_recipients", "expected_personalisation"), [ ( """ @@ -504,7 +504,7 @@ def test_get_recipient( @pytest.mark.parametrize( - "file_contents,template,expected_recipients,expected_personalisation", + ("file_contents", "template", "expected_recipients", "expected_personalisation"), [ ( """ @@ -539,7 +539,7 @@ def test_get_recipient_respects_order( @pytest.mark.parametrize( - "file_contents,template_type,expected,expected_missing", + ("file_contents", "template_type", "expected", "expected_missing"), [ ("", "sms", [], set(["phone number", "name"])), ( @@ -612,7 +612,7 @@ def test_column_headers(file_contents, template_type, expected, expected_missing ], ) @pytest.mark.parametrize( - "file_contents,template_type", + ("file_contents", "template_type"), [ pytest.param("", "sms", marks=pytest.mark.xfail), pytest.param("name", "sms", marks=pytest.mark.xfail), @@ -660,7 +660,12 @@ def test_recipient_column(content, file_contents, template_type): @pytest.mark.parametrize( - "file_contents,template_type,rows_with_bad_recipients,rows_with_missing_data", + ( + "file_contents", + "template_type", + "rows_with_bad_recipients", + "rows_with_missing_data", + ), [ ( """ @@ -761,7 +766,7 @@ def test_bad_or_missing_data( @pytest.mark.parametrize( - "file_contents,rows_with_bad_recipients", + ("file_contents", "rows_with_bad_recipients"), [ ( """ @@ -811,7 +816,7 @@ def test_errors_when_too_many_rows(): @pytest.mark.parametrize( - "file_contents,template_type,guestlist,count_of_rows_with_errors", + ("file_contents", "template_type", "guestlist", "count_of_rows_with_errors"), [ ( """ @@ -938,7 +943,7 @@ def test_detects_rows_which_result_in_empty_messages(): @pytest.mark.parametrize( - "key, expected", + ("key", "expected"), sum( [ [(key, expected) for key in group] @@ -1002,8 +1007,8 @@ def test_ignores_spaces_and_case_in_placeholders(key, expected): @pytest.mark.parametrize( - "character, name", - ( + ("character", "name"), + [ (" ", "SPACE"), # these ones don’t have unicode names ("\n", None), # newline @@ -1017,7 +1022,7 @@ def test_ignores_spaces_and_case_in_placeholders(key, expected): ("\uFEFF", "ZERO WIDTH NO-BREAK SPACE"), # all the things (" \n\r\t\u000A\u000D\u180E\u200B\u200C\u200D\u2060\uFEFF", None), - ), + ], ) def test_ignores_leading_whitespace_in_file(character, name): if name is not None: @@ -1061,7 +1066,7 @@ def test_dont_error_if_too_many_recipients_not_specified(): @pytest.mark.parametrize( - "index, expected_row", + ("index", "expected_row"), [ ( 0, @@ -1106,7 +1111,7 @@ def test_recipients_can_be_accessed_by_index(index, expected_row): assert recipients[index][key].data == value -@pytest.mark.parametrize("international_sms", (True, False)) +@pytest.mark.parametrize("international_sms", [True, False]) def test_multiple_sms_recipient_columns(international_sms): recipients = RecipientCSV( """ @@ -1131,13 +1136,13 @@ def test_multiple_sms_recipient_columns(international_sms): @pytest.mark.parametrize( "column_name", - ( + [ "phone_number", "phonenumber", "phone number", "phone-number", "p h o n e n u m b e r", - ), + ], ) def test_multiple_sms_recipient_columns_with_missing_data(column_name): recipients = RecipientCSV( @@ -1257,12 +1262,12 @@ def test_multi_line_placeholders_work(): @pytest.mark.parametrize( - "extra_args, expected_errors, expected_bad_rows", - ( + ("extra_args", "expected_errors", "expected_bad_rows"), + [ ({}, True, {0}), ({"allow_international_letters": False}, True, {0}), ({"allow_international_letters": True}, False, set()), - ), + ], ) def test_accepts_international_addresses_when_allowed( extra_args, expected_errors, expected_bad_rows diff --git a/tests/notifications_utils/test_recipient_validation.py b/tests/notifications_utils/test_recipient_validation.py index 91360056e..ff48df775 100644 --- a/tests/notifications_utils/test_recipient_validation.py +++ b/tests/notifications_utils/test_recipient_validation.py @@ -153,7 +153,7 @@ def test_detect_us_phone_numbers(phone_number): @pytest.mark.parametrize( - "phone_number, expected_info", + ("phone_number", "expected_info"), [ # ( # "+4407900900123", @@ -285,13 +285,12 @@ def test_valid_us_phone_number_can_be_formatted_consistently(phone_number): @pytest.mark.parametrize( - "phone_number, expected_formatted", + ("phone_number", "expected_formatted"), [ # ("+44071234567890", "+4471234567890"), ("1-202-555-0104", "+12025550104"), ("+12025550104", "+12025550104"), ("12025550104", "+12025550104"), - ("+12025550104", "+12025550104"), # ("+23051234567", "+23051234567"), ], ) @@ -304,7 +303,7 @@ def test_valid_international_phone_number_can_be_formatted_consistently( ) -@pytest.mark.parametrize("phone_number, error_message", invalid_us_phone_numbers) +@pytest.mark.parametrize(("phone_number", "error_message"), invalid_us_phone_numbers) @pytest.mark.parametrize( "extra_args", [ @@ -318,7 +317,7 @@ def test_phone_number_rejects_invalid_values(extra_args, phone_number, error_mes assert error_message == str(e.value) -@pytest.mark.parametrize("phone_number, error_message", invalid_phone_numbers) +@pytest.mark.parametrize(("phone_number", "error_message"), invalid_phone_numbers) def test_phone_number_rejects_invalid_international_values(phone_number, error_message): with pytest.raises(InvalidPhoneError) as e: validate_phone_number(phone_number, international=True) @@ -384,7 +383,7 @@ def test_validates_against_guestlist_of_email_addresses(email_address): @pytest.mark.parametrize( - "phone_number, expected_formatted", + ("phone_number", "expected_formatted"), [ # ("+4407900900123", "+44 7900 900123"), # UK # ("+44(0)7900900123", "+44 7900 900123"), # UK @@ -403,7 +402,7 @@ def test_format_us_and_international_phone_numbers(phone_number, expected_format @pytest.mark.parametrize( - "recipient, expected_formatted", + ("recipient", "expected_formatted"), [ (True, ""), (False, ""), diff --git a/tests/notifications_utils/test_request_header_authentication.py b/tests/notifications_utils/test_request_header_authentication.py index f595619ce..8a5d93cfc 100644 --- a/tests/notifications_utils/test_request_header_authentication.py +++ b/tests/notifications_utils/test_request_header_authentication.py @@ -5,7 +5,7 @@ from notifications_utils.request_helper import NotifyRequest, _check_proxy_heade @pytest.mark.parametrize( - "header,secrets,expected", + ("header", "secrets", "expected"), [ ( {"X-Custom-Forwarder": "right_key"}, @@ -48,7 +48,7 @@ def test_request_header_authorization(header, secrets, expected): @pytest.mark.parametrize( - "secrets,expected", + ("secrets", "expected"), [ (["old_key", "right_key"], (False, "Header missing")), ], diff --git a/tests/notifications_utils/test_safe_string.py b/tests/notifications_utils/test_safe_string.py index a0bf3360f..613dc85af 100644 --- a/tests/notifications_utils/test_safe_string.py +++ b/tests/notifications_utils/test_safe_string.py @@ -7,7 +7,7 @@ from notifications_utils.safe_string import ( @pytest.mark.parametrize( - "unsafe_string, expected_safe", + ("unsafe_string", "expected_safe"), [ ("name with spaces", "name.with.spaces"), ("singleword", "singleword"), @@ -26,7 +26,7 @@ def test_email_safe_return_dot_separated_email_local_part(unsafe_string, expecte @pytest.mark.parametrize( - "unsafe_string, expected_safe", + ("unsafe_string", "expected_safe"), [ ("name with spaces", "name-with-spaces"), ("singleword", "singleword"), diff --git a/tests/notifications_utils/test_sanitise_text.py b/tests/notifications_utils/test_sanitise_text.py index 062f280e0..e8bdf04dd 100644 --- a/tests/notifications_utils/test_sanitise_text.py +++ b/tests/notifications_utils/test_sanitise_text.py @@ -42,7 +42,7 @@ params, ids = zip( ) -@pytest.mark.parametrize("char, expected", params, ids=ids) +@pytest.mark.parametrize(("char", "expected"), params, ids=ids) @pytest.mark.parametrize("cls", [SanitiseSMS, SanitiseASCII]) def test_encode_chars_the_same_for_ascii_and_sms(char, expected, cls): assert cls.encode_char(char) == expected @@ -64,7 +64,7 @@ params, ids = zip( ) -@pytest.mark.parametrize("char, expected_sms, expected_ascii", params, ids=ids) +@pytest.mark.parametrize(("char", "expected_sms", "expected_ascii"), params, ids=ids) def test_encode_chars_different_between_ascii_and_sms( char, expected_sms, expected_ascii ): @@ -73,7 +73,7 @@ def test_encode_chars_different_between_ascii_and_sms( @pytest.mark.parametrize( - "codepoint, char", + ("codepoint", "char"), [ ("0041", "A"), ("0061", "a"), @@ -87,12 +87,12 @@ def test_get_unicode_char_from_codepoint(codepoint, char): "bad_input", ["", "GJ", "00001", '0001";import sys;sys.exit(0)"'] ) def test_get_unicode_char_from_codepoint_rejects_bad_input(bad_input): - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa PT011 SanitiseText.get_unicode_char_from_codepoint(bad_input) @pytest.mark.parametrize( - "content, expected", + ("content", "expected"), [ ("Łōdź", "?odz"), ( @@ -107,7 +107,7 @@ def test_encode_string(content, expected): @pytest.mark.parametrize( - "content, cls, expected", + ("content", "cls", "expected"), [ ("The quick brown fox jumps over the lazy dog", SanitiseSMS, set()), ( @@ -132,7 +132,7 @@ def test_sms_encoding_get_non_compatible_characters(content, cls, expected): @pytest.mark.parametrize( - "content, expected", + ("content", "expected"), [ ("이것은 테스트입니다", True), # Korean ("Αυτό είναι ένα τεστ", True), # Greek @@ -285,7 +285,7 @@ def test_sms_supporting_additional_languages(content, expected): @pytest.mark.parametrize( - "content, expected", + ("content", "expected"), [ ("이것은 테스트입니다", set()), # Korean ("Αυτό είναι ένα τεστ", set()), # Greek diff --git a/tests/notifications_utils/test_serialised_model.py b/tests/notifications_utils/test_serialised_model.py index b83a4d1e5..c1344af48 100644 --- a/tests/notifications_utils/test_serialised_model.py +++ b/tests/notifications_utils/test_serialised_model.py @@ -87,10 +87,10 @@ def test_cant_override_custom_property_from_dict(): @pytest.mark.parametrize( "json_response", - ( + [ {}, {"foo": "bar"}, # Should still raise an exception - ), + ], ) def test_model_raises_for_unknown_attributes(json_response): class Custom(SerialisedModel): @@ -118,10 +118,10 @@ def test_model_raises_keyerror_if_item_missing_from_dict(): @pytest.mark.parametrize( "json_response", - ( + [ {}, {"foo": "bar"}, # Should be ignored - ), + ], ) def test_model_doesnt_swallow_attribute_errors(json_response): class Custom(SerialisedModel): diff --git a/tests/notifications_utils/test_template_change.py b/tests/notifications_utils/test_template_change.py index e0b8df892..12e0f85d3 100644 --- a/tests/notifications_utils/test_template_change.py +++ b/tests/notifications_utils/test_template_change.py @@ -6,7 +6,7 @@ from .test_base_template import ConcreteTemplate @pytest.mark.parametrize( - "old_template, new_template, should_differ", + ("old_template", "new_template", "should_differ"), [ ( ConcreteTemplate({"content": "((1)) ((2)) ((3))"}), @@ -50,7 +50,7 @@ def test_checking_for_difference_between_templates( @pytest.mark.parametrize( - "old_template, new_template, placeholders_added", + ("old_template", "new_template", "placeholders_added"), [ ( ConcreteTemplate({"content": "((1)) ((2)) ((3))"}), @@ -87,7 +87,7 @@ def test_placeholders_added(old_template, new_template, placeholders_added): @pytest.mark.parametrize( - "old_template, new_template, placeholders_removed", + ("old_template", "new_template", "placeholders_removed"), [ ( ConcreteTemplate({"content": "((1)) ((2)) ((3))"}), diff --git a/tests/notifications_utils/test_template_types.py b/tests/notifications_utils/test_template_types.py index 1209d4dc9..1b119f216 100644 --- a/tests/notifications_utils/test_template_types.py +++ b/tests/notifications_utils/test_template_types.py @@ -32,8 +32,8 @@ from notifications_utils.template import ( @pytest.mark.parametrize( - "template_class, expected_error", - ( + ("template_class", "expected_error"), + [ pytest.param( Template, ("Can't instantiate abstract class Template with abstract method __str__"), @@ -104,7 +104,7 @@ from notifications_utils.template import ( sys.version_info < (3, 9), reason="‘method’ will be pluralised" ), ), - ), + ], ) def test_abstract_classes_cant_be_instantiated(template_class, expected_error): with pytest.raises(TypeError) as error: @@ -114,8 +114,8 @@ def test_abstract_classes_cant_be_instantiated(template_class, expected_error): @pytest.mark.parametrize( - "template_class, expected_error", - ( + ("template_class", "expected_error"), + [ ( HTMLEmailTemplate, ("Cannot initialise HTMLEmailTemplate with sms template_type"), @@ -128,7 +128,7 @@ def test_abstract_classes_cant_be_instantiated(template_class, expected_error): BroadcastPreviewTemplate, ("Cannot initialise BroadcastPreviewTemplate with sms template_type"), ), - ), + ], ) def test_errors_for_incompatible_template_type(template_class, expected_error): with pytest.raises(TypeError) as error: @@ -149,7 +149,7 @@ def test_html_email_inserts_body(): @pytest.mark.parametrize( - "content", ("DOCTYPE", "html", "body", "beta.notify.gov", "hello world") + "content", ["DOCTYPE", "html", "body", "beta.notify.gov", "hello world"] ) def test_default_template(content): assert content in str( @@ -163,7 +163,7 @@ def test_default_template(content): ) -@pytest.mark.parametrize("show_banner", (True, False)) +@pytest.mark.parametrize("show_banner", [True, False]) def test_govuk_banner(show_banner): email = HTMLEmailTemplate( { @@ -194,7 +194,7 @@ def test_brand_banner_shows(): @pytest.mark.parametrize( - "brand_logo, brand_text, brand_colour", + ("brand_logo", "brand_text", "brand_colour"), [ ("http://example.com/image.png", "Example", "red"), ("http://example.com/image.png", "Example", "#f00"), @@ -255,7 +255,7 @@ def test_alt_text_with_no_brand_text_and_govuk_banner_shown(): @pytest.mark.parametrize( - "brand_banner, brand_text, expected_alt_text", + ("brand_banner", "brand_text", "expected_alt_text"), [ (True, None, 'alt="Notify Logo"'), (True, "Example", 'alt=""'), @@ -278,9 +278,9 @@ def test_alt_text_with_no_govuk_banner(brand_banner, brand_text, expected_alt_te assert expected_alt_text in email -@pytest.mark.parametrize("complete_html", (True, False)) +@pytest.mark.parametrize("complete_html", [True, False]) @pytest.mark.parametrize( - "branding_should_be_present, brand_logo, brand_text, brand_colour", + ("branding_should_be_present", "brand_logo", "brand_text", "brand_colour"), [ (True, "http://example.com/image.png", "Example", "#f00"), (True, "http://example.com/image.png", "Example", None), @@ -289,7 +289,7 @@ def test_alt_text_with_no_govuk_banner(brand_banner, brand_text, expected_alt_te (False, "http://example.com/image.png", None, "#f00"), ], ) -@pytest.mark.parametrize("content", ("DOCTYPE", "html", "body")) +@pytest.mark.parametrize("content", ["DOCTYPE", "html", "body"]) def test_complete_html( complete_html, branding_should_be_present, @@ -351,7 +351,7 @@ def test_preheader_is_at_start_of_html_emails(): @pytest.mark.parametrize( - "content, values, expected_preheader", + ("content", "values", "expected_preheader"), [ ( ( @@ -426,22 +426,22 @@ def test_content_of_preheader_in_html_emails( @pytest.mark.parametrize( - "template_class, template_type, extra_args, result, markdown_renderer", + ("template_class", "template_type", "extra_args", "result", "markdown_renderer"), [ - [ + ( HTMLEmailTemplate, "email", {}, ("the quick brown fox\n" "\n" "jumped over the lazy dog\n"), "notifications_utils.template.notify_email_markdown", - ], - [ + ), + ( LetterPreviewTemplate, "letter", {}, ("the quick brown fox\n" "\n" "jumped over the lazy dog\n"), "notifications_utils.template.notify_letter_preview_markdown", - ], + ), ], ) def test_markdown_in_templates( @@ -471,7 +471,7 @@ def test_markdown_in_templates( @pytest.mark.parametrize( - "template_class, template_type, extra_attributes", + ("template_class", "template_type", "extra_attributes"), [ (HTMLEmailTemplate, "email", 'style="word-wrap: break-word; color: #1D70B8;"'), ( @@ -494,7 +494,7 @@ def test_markdown_in_templates( ], ) @pytest.mark.parametrize( - "url, url_with_entities_replaced", + ("url", "url_with_entities_replaced"), [ ("http://example.com", "http://example.com"), ("http://www.gov.uk/", "http://www.gov.uk/"), @@ -530,15 +530,15 @@ def test_makes_links_out_of_URLs( @pytest.mark.parametrize( - "template_class, template_type", - ( + ("template_class", "template_type"), + [ (SMSPreviewTemplate, "sms"), (BroadcastPreviewTemplate, "broadcast"), - ), + ], ) @pytest.mark.parametrize( - "url, url_with_entities_replaced", - ( + ("url", "url_with_entities_replaced"), + [ ("example.com", "example.com"), ("www.gov.uk/", "www.gov.uk/"), ("service.gov.uk", "service.gov.uk"), @@ -547,7 +547,7 @@ def test_makes_links_out_of_URLs( "service.gov.uk/blah.ext?q=a%20b%20c&order=desc#fragment", "service.gov.uk/blah.ext?q=a%20b%20c&order=desc#fragment", ), - ), + ], ) def test_makes_links_out_of_URLs_without_protocol_in_sms_and_broadcast( template_class, @@ -567,8 +567,8 @@ def test_makes_links_out_of_URLs_without_protocol_in_sms_and_broadcast( @pytest.mark.parametrize( - "content, html_snippet", - ( + ("content", "html_snippet"), + [ ( ( "You've been invited to a service. Click this link:\n" @@ -592,7 +592,7 @@ def test_makes_links_out_of_URLs_without_protocol_in_sms_and_broadcast( "" ), ), - ), + ], ) def test_HTML_template_has_URLs_replaced_with_links(content, html_snippet): assert html_snippet in str( @@ -601,7 +601,7 @@ def test_HTML_template_has_URLs_replaced_with_links(content, html_snippet): @pytest.mark.parametrize( - "template_content,expected", + ("template_content", "expected"), [ ("gov.uk", "gov.\u200Buk"), ("GOV.UK", "GOV.\u200BUK"), @@ -660,7 +660,7 @@ def test_stripping_of_unsupported_characters_in_email_templates(): @mock.patch("notifications_utils.template.add_prefix", return_value="") @pytest.mark.parametrize( - "template_class, prefix, body, expected_call", + ("template_class", "prefix", "body", "expected_call"), [ (SMSMessageTemplate, "a", "b", (Markup("b"), "a")), (SMSPreviewTemplate, "a", "b", (Markup("b"), "a")), @@ -705,7 +705,7 @@ def test_sms_message_adds_prefix( ], ) @pytest.mark.parametrize( - "show_prefix, prefix, body, sender, expected_call", + ("show_prefix", "prefix", "body", "sender", "expected_call"), [ (False, "a", "b", "c", (Markup("b"), None)), (True, "a", "b", None, (Markup("b"), "a")), @@ -761,14 +761,14 @@ def test_sms_message_preview_hides_sender_by_default(): @mock.patch("notifications_utils.template.sms_encode", return_value="downgraded") @pytest.mark.parametrize( - "template_class, extra_args, expected_call", - ( + ("template_class", "extra_args", "expected_call"), + [ (SMSMessageTemplate, {"prefix": "Service name"}, "Service name: Message"), (SMSPreviewTemplate, {"prefix": "Service name"}, "Service name: Message"), (BroadcastMessageTemplate, {}, "Message"), (BroadcastPreviewTemplate, {"prefix": "Service name"}, "Service name: Message"), (SMSBodyPreviewTemplate, {}, "Message"), - ), + ], ) def test_sms_messages_downgrade_non_sms( mock_sms_encode, @@ -788,10 +788,10 @@ def test_sms_messages_downgrade_non_sms( @pytest.mark.parametrize( "template_class", - ( + [ SMSPreviewTemplate, BroadcastPreviewTemplate, - ), + ], ) @mock.patch("notifications_utils.template.sms_encode", return_value="downgraded") def test_sms_messages_dont_downgrade_non_sms_if_setting_is_false( @@ -810,10 +810,10 @@ def test_sms_messages_dont_downgrade_non_sms_if_setting_is_false( @pytest.mark.parametrize( "template_class", - ( + [ SMSPreviewTemplate, BroadcastPreviewTemplate, - ), + ], ) @mock.patch("notifications_utils.template.nl2br") def test_sms_preview_adds_newlines(nl2br, template_class): @@ -862,13 +862,13 @@ def test_broadcast_message_normalises_newlines(content): @pytest.mark.parametrize( "template_class", - ( + [ SMSMessageTemplate, SMSBodyPreviewTemplate, BroadcastMessageTemplate, # Note: SMSPreviewTemplate and BroadcastPreviewTemplate not tested here # as both will render full HTML template, not just the body - ), + ], ) def test_phone_templates_normalise_whitespace(template_class): content = " Hi\u00A0there\u00A0 what's\u200D up\t" @@ -889,7 +889,7 @@ def test_phone_templates_normalise_whitespace(template_class): "notifications_utils.template.notify_letter_preview_markdown", return_value="Bar" ) @pytest.mark.parametrize( - "values, expected_address", + ("values", "expected_address"), [ ( {}, @@ -933,7 +933,7 @@ def test_phone_templates_normalise_whitespace(template_class): ], ) @pytest.mark.parametrize( - "contact_block, expected_rendered_contact_block", + ("contact_block", "expected_rendered_contact_block"), [ (None, ""), ("", ""), @@ -962,14 +962,14 @@ def test_phone_templates_normalise_whitespace(template_class): ], ) @pytest.mark.parametrize( - "extra_args, expected_logo_file_name, expected_logo_class", + ("extra_args", "expected_logo_file_name", "expected_logo_class"), [ ({}, None, None), ({"logo_file_name": "example.foo"}, "example.foo", "foo"), ], ) @pytest.mark.parametrize( - "additional_extra_args, expected_date", + ("additional_extra_args", "expected_date"), [ ({}, "12 December 2012"), ({"date": None}, "12 December 2012"), @@ -1044,7 +1044,7 @@ def test_letter_preview_renderer_without_mocks(jinja_template): @freeze_time("2012-12-12 12:12:12") @mock.patch("notifications_utils.template.LetterImageTemplate.jinja_template.render") @pytest.mark.parametrize( - "page_count, expected_oversized, expected_page_numbers", + ("page_count", "expected_oversized", "expected_page_numbers"), [ ( 1, @@ -1074,8 +1074,13 @@ def test_letter_preview_renderer_without_mocks(jinja_template): ], ) @pytest.mark.parametrize( - "postage_args, expected_show_postage, expected_postage_class_value, expected_postage_description", ( + "postage_args", + "expected_show_postage", + "expected_postage_class_value", + "expected_postage_description", + ), + [ pytest.param({}, False, None, None), pytest.param({"postage": None}, False, None, None), pytest.param({"postage": "first"}, True, "letter-postage-first", "first class"), @@ -1098,7 +1103,7 @@ def test_letter_preview_renderer_without_mocks(jinja_template): "third class", marks=pytest.mark.xfail(raises=TypeError), ), - ), + ], ) def test_letter_image_renderer( jinja_template, @@ -1147,13 +1152,13 @@ def test_letter_image_renderer( @mock.patch("notifications_utils.template.LetterImageTemplate.jinja_template.render") @pytest.mark.parametrize( "postage_argument", - ( + [ None, "first", "second", "europe", "rest-of-world", - ), + ], ) def test_letter_image_renderer_shows_international_post( jinja_template, @@ -1219,7 +1224,7 @@ def test_letter_image_renderer_pagination(page_image_url): @pytest.mark.parametrize( - "partial_call, expected_exception, expected_message", + ("partial_call", "expected_exception", "expected_message"), [ ( partial(LetterImageTemplate), @@ -1261,8 +1266,8 @@ def test_letter_image_renderer_requires_arguments( @pytest.mark.parametrize( - "postage, expected_attribute_value, expected_postage_text", - ( + ("postage", "expected_attribute_value", "expected_postage_text"), + [ (None, None, None), ( "first", @@ -1284,7 +1289,7 @@ def test_letter_image_renderer_requires_arguments( ["letter-postage", "letter-postage-international"], "Postage: international", ), - ), + ], ) def test_letter_image_renderer_passes_postage_to_html_attribute( postage, @@ -1315,20 +1320,20 @@ def test_letter_image_renderer_passes_postage_to_html_attribute( @pytest.mark.parametrize( "template_class", - ( + [ SMSBodyPreviewTemplate, SMSMessageTemplate, SMSPreviewTemplate, BroadcastMessageTemplate, BroadcastPreviewTemplate, - ), + ], ) @pytest.mark.parametrize( "template_json", - ( + [ {"content": ""}, {"content": "", "subject": "subject"}, - ), + ], ) def test_sms_templates_have_no_subject(template_class, template_json): template_json.update(template_type=template_class.template_type) @@ -1358,8 +1363,8 @@ def test_subject_line_gets_applied_to_correct_template_types(): @pytest.mark.parametrize( - "template_class, template_type, extra_args", - ( + ("template_class", "template_type", "extra_args"), + [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), (PlainTextEmailTemplate, "email", {}), @@ -1373,7 +1378,7 @@ def test_subject_line_gets_applied_to_correct_template_types(): "page_count": 1, }, ), - ), + ], ) def test_subject_line_gets_replaced(template_class, template_type, extra_args): template = template_class( @@ -1386,8 +1391,8 @@ def test_subject_line_gets_replaced(template_class, template_type, extra_args): @pytest.mark.parametrize( - "template_class, template_type, extra_args", - ( + ("template_class", "template_type", "extra_args"), + [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), (PlainTextEmailTemplate, "email", {}), @@ -1401,10 +1406,10 @@ def test_subject_line_gets_replaced(template_class, template_type, extra_args): "page_count": 1, }, ), - ), + ], ) @pytest.mark.parametrize( - "content, values, expected_count", + ("content", "values", "expected_count"), [ ("Content with ((placeholder))", {"placeholder": "something extra"}, 28), ("Content with ((placeholder))", {"placeholder": ""}, 12), @@ -1441,7 +1446,13 @@ def test_character_count_for_non_sms_templates( ], ) @pytest.mark.parametrize( - "content, values, prefix, expected_count_in_template, expected_count_in_notification", + ( + "content", + "values", + "prefix", + "expected_count_in_template", + "expected_count_in_notification", + ), [ # is an unsupported unicode character so should be replaced with a ? ("深", {}, None, 1, 1), @@ -1507,7 +1518,12 @@ def test_character_count_for_sms_templates( ], ) @pytest.mark.parametrize( - "content, values, expected_count_in_template, expected_count_in_notification", + ( + "content", + "values", + "expected_count_in_template", + "expected_count_in_notification", + ), [ # is an unsupported unicode character so should be replaced with a ? ("深", {}, 1, 1), @@ -1546,13 +1562,13 @@ def test_character_count_for_broadcast_templates( @pytest.mark.parametrize( "template_class", - ( + [ SMSMessageTemplate, BroadcastMessageTemplate, - ), + ], ) @pytest.mark.parametrize( - "msg, expected_sms_fragment_count", + ("msg", "expected_sms_fragment_count"), [ ( """This is a very long long long long long long long long long long @@ -1575,13 +1591,13 @@ def test_sms_fragment_count_accounts_for_unicode_and_welsh_characters( @pytest.mark.parametrize( "template_class", - ( + [ SMSMessageTemplate, BroadcastMessageTemplate, - ), + ], ) @pytest.mark.parametrize( - "msg, expected_sms_fragment_count", + ("msg", "expected_sms_fragment_count"), [ # all extended GSM characters ( @@ -1647,7 +1663,7 @@ def test_sms_fragment_count_accounts_for_non_latin_characters( ], ) @pytest.mark.parametrize( - "content, values, prefix, expected_result", + ("content", "values", "prefix", "expected_result"), [ ("", {}, None, True), ("", {}, "GDS", True), @@ -1676,7 +1692,7 @@ def test_is_message_empty_sms_templates( ], ) @pytest.mark.parametrize( - "content, values, expected_result", + ("content", "values", "expected_result"), [ ("", {}, True), ("((placeholder))", {"placeholder": ""}, True), @@ -1696,14 +1712,14 @@ def test_is_message_empty_broadcast_templates( @pytest.mark.parametrize( - "template_class, template_type", - ( + ("template_class", "template_type"), + [ (HTMLEmailTemplate, "email"), (LetterPrintTemplate, "letter"), - ), + ], ) @pytest.mark.parametrize( - "content, values, expected_result", + ("content", "values", "expected_result"), [ ("", {}, True), ("((placeholder))", {"placeholder": ""}, True), @@ -1735,14 +1751,14 @@ def test_is_message_empty_email_and_letter_templates( @pytest.mark.parametrize( - "template_class, template_type", - ( + ("template_class", "template_type"), + [ (HTMLEmailTemplate, "email"), (LetterPrintTemplate, "letter"), - ), + ], ) @pytest.mark.parametrize( - "content, values", + ("content", "values"), [ ("Some content", {}), ("((placeholder)) some content", {"placeholder": ""}), @@ -1781,7 +1797,7 @@ def test_is_message_empty_email_and_letter_templates_tries_not_to_count_chars( @pytest.mark.parametrize( - "template_class, template_type, extra_args, expected_field_calls", + ("template_class", "template_type", "extra_args", "expected_field_calls"), [ ( PlainTextEmailTemplate, @@ -2054,7 +2070,12 @@ def test_templates_handle_html_and_redacting( @pytest.mark.parametrize( - "template_class, template_type, extra_args, expected_remove_whitespace_calls", + ( + "template_class", + "template_type", + "extra_args", + "expected_remove_whitespace_calls", + ), [ ( PlainTextEmailTemplate, @@ -2176,7 +2197,7 @@ def test_templates_remove_whitespace_before_punctuation( @pytest.mark.parametrize( - "template_class, template_type, extra_args, expected_calls", + ("template_class", "template_type", "extra_args", "expected_calls"), [ ( PlainTextEmailTemplate, @@ -2259,18 +2280,18 @@ def test_templates_make_quotes_smart_and_dashes_en( @pytest.mark.parametrize( "content", - ( + [ "first.o'last@example.com", "first.o’last@example.com", - ), + ], ) @pytest.mark.parametrize( "template_class", - ( + [ HTMLEmailTemplate, PlainTextEmailTemplate, EmailPreviewTemplate, - ), + ], ) def test_no_smart_quotes_in_email_addresses(template_class, content): template = template_class( @@ -2302,7 +2323,7 @@ def test_smart_quotes_removed_from_long_template_in_under_a_second(): @pytest.mark.parametrize( - "template_instance, expected_placeholders", + ("template_instance", "expected_placeholders"), [ ( SMSMessageTemplate( @@ -2465,7 +2486,7 @@ def test_email_preview_shows_reply_to_address(extra_args): @pytest.mark.parametrize( - "template_values, expected_content", + ("template_values", "expected_content"), [ ({}, "email address"), ({"email address": "test@example.com"}, "test@example.com"), @@ -2483,7 +2504,7 @@ def test_email_preview_shows_recipient_address( @pytest.mark.parametrize( - "address, expected", + ("address", "expected"), [ ( { @@ -2585,7 +2606,7 @@ def test_email_preview_shows_recipient_address( ), ], ) -@pytest.mark.parametrize("template_class", (LetterPreviewTemplate, LetterPrintTemplate)) +@pytest.mark.parametrize("template_class", [LetterPreviewTemplate, LetterPrintTemplate]) def test_letter_address_format(template_class, address, expected): template = BeautifulSoup( str( @@ -2601,7 +2622,7 @@ def test_letter_address_format(template_class, address, expected): @freeze_time("2001-01-01 12:00:00.000000") @pytest.mark.parametrize( - "markdown, expected", + ("markdown", "expected"), [ ( ( @@ -2691,11 +2712,11 @@ def test_message_is_not_too_long_ignoring_prefix(template_class): @pytest.mark.parametrize( - "extra_characters, expected_too_long", - ( + ("extra_characters", "expected_too_long"), + [ ("cc", True), # content length is 919 characters (more than limit of 918) ("c", False), # content length is 918 characters (not more than limit of 918) - ), + ], ) @pytest.mark.parametrize( "template_class", @@ -2716,7 +2737,7 @@ def test_broadcast_message_too_long( @pytest.mark.parametrize( - "template_class, template_type, kwargs", + ("template_class", "template_type", "kwargs"), [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), @@ -2736,7 +2757,7 @@ def test_message_too_long_limit_bigger_or_nonexistent_for_non_sms_templates( @pytest.mark.parametrize( - "template_class, template_type, kwargs", + ("template_class", "template_type", "kwargs"), [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), @@ -2755,7 +2776,7 @@ def test_content_size_in_bytes_for_email_messages( @pytest.mark.parametrize( - "template_class, template_type, kwargs", + ("template_class", "template_type", "kwargs"), [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), @@ -2774,7 +2795,7 @@ def test_message_too_long_for_a_too_big_email_message( @pytest.mark.parametrize( - "template_class, template_type, kwargs", + ("template_class", "template_type", "kwargs"), [ (EmailPreviewTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), @@ -2792,7 +2813,7 @@ def test_message_too_long_for_an_email_message_within_limits( @pytest.mark.parametrize( - ("content," "expected_preview_markup,"), + ("content", "expected_preview_markup"), [ ( "a\n\n\nb", @@ -2847,7 +2868,7 @@ def test_multiple_newlines_in_letters( ], ) @pytest.mark.parametrize( - "template_class, template_type, extra_args", + ("template_class", "template_type", "extra_args"), [ (PlainTextEmailTemplate, "email", {}), (HTMLEmailTemplate, "email", {}), @@ -2886,7 +2907,7 @@ def test_whitespace_in_subject_placeholders(template_class): @pytest.mark.parametrize( - "template_class, expected_output", + ("template_class", "expected_output"), [ ( PlainTextEmailTemplate, @@ -3041,8 +3062,8 @@ def test_plain_text_email_whitespace(): @pytest.mark.parametrize( - "renderer, template_type, expected_content", - ( + ("renderer", "template_type", "expected_content"), + [ ( PlainTextEmailTemplate, "email", @@ -3071,7 +3092,7 @@ def test_plain_text_email_whitespace(): "letter", ("