Normalize whitespace in test arguments

We have a bunch of different styles of handling when function
definitions span multiple lines, which they almost always do with tests.

Here’s why an argument per line, single indent is best:
- cleaner diffs when you change the name of a method (one line change
  instead of multiple lines)
- works better on narrow screens, eg Github’s diff view, or with two
  terminals side by side on a laptop screen
- works with any editor’s indenting shortcuts, no need for an IDE

Also, trailing comma in the list of arguments is good because adding a
new argument to a method becomes a one line, not two line diff.
This commit is contained in:
Chris Hill-Scott
2017-02-03 10:42:01 +00:00
parent b9d88cccc3
commit 929dc45224
28 changed files with 1547 additions and 1103 deletions

View File

@@ -3,11 +3,13 @@ from flask import url_for
from bs4 import BeautifulSoup
def test_should_render_email_verification_resend_show_email_address_and_resend_verify_email(app_,
mocker,
api_user_active,
mock_get_user_by_email,
mock_send_verify_email):
def test_should_render_email_verification_resend_show_email_address_and_resend_verify_email(
app_,
mocker,
api_user_active,
mock_get_user_by_email,
mock_send_verify_email,
):
with app_.test_request_context():
with app_.test_client() as client:
@@ -28,10 +30,12 @@ def test_should_render_email_verification_resend_show_email_address_and_resend_v
mock_send_verify_email.assert_called_with(api_user_active.id, api_user_active.email_address)
def test_should_render_correct_resend_template_for_active_user(app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code):
def test_should_render_correct_resend_template_for_active_user(
app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code,
):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
@@ -47,10 +51,12 @@ def test_should_render_correct_resend_template_for_active_user(app_,
assert page.find('form') is None
def test_should_render_correct_resend_template_for_pending_user(app_,
mocker,
api_user_pending,
mock_send_verify_code):
def test_should_render_correct_resend_template_for_pending_user(
app_,
mocker,
api_user_pending,
mock_send_verify_code,
):
mocker.patch('app.user_api_client.get_user_by_email', return_value=api_user_pending)
@@ -72,11 +78,13 @@ def test_should_render_correct_resend_template_for_pending_user(app_,
assert page.find('form').input['value'] == api_user_pending.mobile_number
def test_should_resend_verify_code_and_update_mobile_for_pending_user(app_,
mocker,
api_user_pending,
mock_update_user,
mock_send_verify_code):
def test_should_resend_verify_code_and_update_mobile_for_pending_user(
app_,
mocker,
api_user_pending,
mock_update_user,
mock_send_verify_code,
):
mocker.patch('app.user_api_client.get_user_by_email', return_value=api_user_pending)
@@ -95,10 +103,12 @@ def test_should_resend_verify_code_and_update_mobile_for_pending_user(app_,
mock_send_verify_code.assert_called_once_with(api_user_pending.id, 'sms', to='+447700900460')
def test_check_and_redirect_to_two_factor_if_user_active(app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code):
def test_check_and_redirect_to_two_factor_if_user_active(
app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code,
):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
@@ -110,11 +120,13 @@ def test_check_and_redirect_to_two_factor_if_user_active(app_,
assert response.location == url_for('main.two_factor', _external=True)
def test_check_and_redirect_to_verify_if_user_pending(app_,
mocker,
api_user_pending,
mock_get_user_pending,
mock_send_verify_code):
def test_check_and_redirect_to_verify_if_user_pending(
app_,
mocker,
api_user_pending,
mock_get_user_pending,
mock_send_verify_code,
):
mocker.patch('app.user_api_client.get_user_by_email', return_value=api_user_pending)
@@ -134,7 +146,10 @@ def test_check_and_redirect_to_verify_if_user_pending(app_,
'main.check_and_resend_text_code',
'main.check_and_resend_verification_code',
])
def test_redirect_to_sign_in_if_not_logged_in(app_, endpoint):
def test_redirect_to_sign_in_if_not_logged_in(
app_,
endpoint,
):
with app_.test_request_context(), app_.test_client() as client:
response = client.get(url_for(endpoint))