diff --git a/payments/mercadopago/test_mercadopago.py b/payments/mercadopago/test_mercadopago.py index 7a0527ec8..a5111dc61 100644 --- a/payments/mercadopago/test_mercadopago.py +++ b/payments/mercadopago/test_mercadopago.py @@ -202,14 +202,17 @@ def test_approved_payment_notification(rf, mp_provider: MercadoPagoProvider): "status": 200, } - with patch( - "mercadopago.resources.payment.Payment.get", - spec=True, - return_value=payment_info_response, - ) as payment_info, patch( - "payments.mercadopago.redirect", - spec=True, - ) as redirect: + with ( + patch( + "mercadopago.resources.payment.Payment.get", + spec=True, + return_value=payment_info_response, + ) as payment_info, + patch( + "payments.mercadopago.redirect", + spec=True, + ) as redirect, + ): rv = mp_provider.process_data(payment, request) assert payment_info.call_count == 1 @@ -232,13 +235,16 @@ def test_create_preference_failure(mp_provider: MercadoPagoProvider): payment = Payment() - with patch( - "mercadopago.resources.preference.Preference.create", - spec=True, - return_value=preference_info, - ), pytest.raises( - PaymentError, - match="Failed to create MercadoPago preference.", + with ( + patch( + "mercadopago.resources.preference.Preference.create", + spec=True, + return_value=preference_info, + ), + pytest.raises( + PaymentError, + match="Failed to create MercadoPago preference.", + ), ): mp_provider.create_preference(payment) @@ -266,13 +272,16 @@ def test_process_failed_collection(mp_provider: MercadoPagoProvider): } payment = Payment() - with patch( - "mercadopago.resources.payment.Payment.get", - spec=True, - return_value=payment_info, - ), pytest.raises( - PaymentError, - match="MercadoPago sent invalid payment data.", + with ( + patch( + "mercadopago.resources.payment.Payment.get", + spec=True, + return_value=payment_info, + ), + pytest.raises( + PaymentError, + match="MercadoPago sent invalid payment data.", + ), ): mp_provider.process_collection(payment, "12") @@ -331,12 +340,13 @@ def test_get_preference_internal_error(mp_provider: MercadoPagoProvider): payment = Payment() payment.transaction_id = "ABJ122" - with patch( - "mercadopago.resources.preference.Preference.get", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises( - PaymentError, match="Failed to retrieve MercadoPago preference." + with ( + patch( + "mercadopago.resources.preference.Preference.get", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(PaymentError, match="Failed to retrieve MercadoPago preference."), ): mp_provider.get_preference(payment) @@ -365,11 +375,14 @@ def test_get_form_for_existing_preference( payment = Payment() payment.transaction_id = "ABJ122" - with patch( - "mercadopago.resources.preference.Preference.get", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises(RedirectNeeded) as exc_info: + with ( + patch( + "mercadopago.resources.preference.Preference.get", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(RedirectNeeded) as exc_info, + ): mp_provider.get_form(payment) assert get_preference.call_count == 1 @@ -387,11 +400,14 @@ def test_get_form_for_inexistent_preference(mp_provider: MercadoPagoProvider): } payment = Payment() - with patch( - "mercadopago.resources.preference.Preference.create", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises(RedirectNeeded) as exc_info: + with ( + patch( + "mercadopago.resources.preference.Preference.create", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(RedirectNeeded) as exc_info, + ): mp_provider.get_form(payment) assert get_preference.call_count == 1 diff --git a/payments/models.py b/payments/models.py index fe5203aee..303492033 100644 --- a/payments/models.py +++ b/payments/models.py @@ -2,7 +2,7 @@ import json import logging -from typing import Iterable +from collections.abc import Iterable from uuid import uuid4 from django.db import models