From d06703a808c16068b3aeb7794f4dd991f3a5714a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 01:07:03 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- fixtures/common.py | 8 ++++---- fixtures/users.py | 18 +++++++++--------- payments/api_test.py | 12 ++++++------ payments/hooks/post_sale_test.py | 2 +- repl.py | 2 +- system_meta/views_test.py | 4 ++-- unified_ecommerce/celery.py | 2 +- unified_ecommerce/test_utils.py | 2 +- unified_ecommerce/utils_test.py | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/fixtures/common.py b/fixtures/common.py index 1dadaaeb..5c11f744 100644 --- a/fixtures/common.py +++ b/fixtures/common.py @@ -48,13 +48,13 @@ def warnings_as_errors(): # noqa: PT004 warnings.resetwarnings() -@pytest.fixture() +@pytest.fixture def randomness(): # noqa: PT004 """Ensure a fixed seed for factoryboy""" factory.fuzzy.reseed_random("happy little clouds") -@pytest.fixture() +@pytest.fixture def mocked_celery(mocker): """Mock object that patches certain celery functions""" exception_class = TabError @@ -72,13 +72,13 @@ def mocked_celery(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_context(mocker, user): """Mock context for serializers""" return {"request": mocker.Mock(user=user)} -@pytest.fixture() +@pytest.fixture def mocked_responses(): """Mock responses fixture""" with responses.RequestsMock() as rsps: diff --git a/fixtures/users.py b/fixtures/users.py index 373ae84c..688898b5 100644 --- a/fixtures/users.py +++ b/fixtures/users.py @@ -11,26 +11,26 @@ from unified_ecommerce.factories import UserFactory -@pytest.fixture() +@pytest.fixture def user(db): # noqa: ARG001 """Create a user""" return UserFactory.create() -@pytest.fixture() +@pytest.fixture def staff_user(db): # noqa: ARG001 """Create a staff user""" return UserFactory.create(is_staff=True) -@pytest.fixture() +@pytest.fixture def logged_in_user(client, user): """Log the user in and yield the user object""" client.force_login(user) return user -@pytest.fixture() +@pytest.fixture def logged_in_profile(client): """Add a Profile and logged-in User""" user = UserFactory.create(username="george") @@ -38,7 +38,7 @@ def logged_in_profile(client): return user.profile -@pytest.fixture() +@pytest.fixture def jwt_token(db, user, client, rf, settings): # noqa: ARG001 """Creates a JWT token for a regular user""" # noqa: D401 jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER @@ -50,7 +50,7 @@ def jwt_token(db, user, client, rf, settings): # noqa: ARG001 return token -@pytest.fixture() +@pytest.fixture def client(db): # noqa: ARG001 """ Similar to the builtin client but this provides the DRF client instead of the Django test client. @@ -58,7 +58,7 @@ def client(db): # noqa: ARG001 return APIClient() -@pytest.fixture() +@pytest.fixture def user_client(user): """Version of the client that is authenticated with the user""" client = APIClient() @@ -66,7 +66,7 @@ def user_client(user): return client -@pytest.fixture() +@pytest.fixture def staff_client(staff_user): """Version of the client that is authenticated with the staff_user""" client = APIClient() @@ -74,7 +74,7 @@ def staff_client(staff_user): return client -@pytest.fixture() +@pytest.fixture def profile_image(): """Create a PNG image""" image_file = BytesIO() diff --git a/payments/api_test.py b/payments/api_test.py index db485163..d0ad352b 100644 --- a/payments/api_test.py +++ b/payments/api_test.py @@ -48,13 +48,13 @@ pytestmark = [pytest.mark.django_db] -@pytest.fixture() +@pytest.fixture def fulfilled_order(): """Fixture for creating a fulfilled order""" return OrderFactory.create(state=Order.STATE.FULFILLED) -@pytest.fixture() +@pytest.fixture def fulfilled_transaction(fulfilled_order): """Fixture to creating a fulfilled transaction""" payment_amount = 10.00 @@ -72,7 +72,7 @@ def fulfilled_transaction(fulfilled_order): ) -@pytest.fixture() +@pytest.fixture def fulfilled_paypal_transaction(fulfilled_order): """Fixture to creating a fulfilled transaction""" payment_amount = 10.00 @@ -98,7 +98,7 @@ def fulfilled_paypal_transaction(fulfilled_order): ) -@pytest.fixture() +@pytest.fixture def fulfilled_complete_order(): """Create a fulfilled order with line items.""" @@ -113,14 +113,14 @@ def fulfilled_complete_order(): return order -@pytest.fixture() +@pytest.fixture def products(): """Create products""" with reversion.create_revision(): return ProductFactory.create_batch(5) -@pytest.fixture() +@pytest.fixture def user(db): """Create a user""" return UserFactory.create() diff --git a/payments/hooks/post_sale_test.py b/payments/hooks/post_sale_test.py index 9baa85e1..78f6a6e1 100644 --- a/payments/hooks/post_sale_test.py +++ b/payments/hooks/post_sale_test.py @@ -11,7 +11,7 @@ pytestmark = [pytest.mark.django_db] -@pytest.fixture() +@pytest.fixture def pending_complete_order(): """Create a pending order with line items.""" diff --git a/repl.py b/repl.py index 9939a414..161b5a21 100755 --- a/repl.py +++ b/repl.py @@ -12,7 +12,7 @@ sys.exit( check_call( - [ # noqa: S603 + [ os.path.join(base_dir, "manage.py"), # noqa: PTH118 "shell", *sys.argv[1:], diff --git a/system_meta/views_test.py b/system_meta/views_test.py index 92ee4cf6..ef27ca8e 100644 --- a/system_meta/views_test.py +++ b/system_meta/views_test.py @@ -132,7 +132,7 @@ def test_update( # noqa: PLR0913 ), ], ) - def test_delete( # noqa: PLR0913 + def test_delete( self, is_logged_in, use_staff_user, client, user_client, staff_client ): """Test that the viewset can delete an object.""" @@ -309,7 +309,7 @@ def test_update( # noqa: PLR0913 ), ], ) - def test_delete( # noqa: PLR0913 + def test_delete( self, is_logged_in, use_staff_user, client, user_client, staff_client ): """Test that the viewset can delete an object.""" diff --git a/unified_ecommerce/celery.py b/unified_ecommerce/celery.py index 5d8fdb10..850a4b95 100644 --- a/unified_ecommerce/celery.py +++ b/unified_ecommerce/celery.py @@ -9,7 +9,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "unified_ecommerce.settings") -from django.conf import settings # noqa: E402 +from django.conf import settings app = Celery("unified_ecommerce") app.config_from_object("django.conf:settings", namespace="CELERY") diff --git a/unified_ecommerce/test_utils.py b/unified_ecommerce/test_utils.py index 1631814e..c533a452 100644 --- a/unified_ecommerce/test_utils.py +++ b/unified_ecommerce/test_utils.py @@ -538,7 +538,7 @@ def _test_retrieval(self, api_client, url, url_name, **kwargs): # noqa: ARG002 assert response.status_code < 500 return response - def _determine_client_wrapper( # noqa: PLR0913 + def _determine_client_wrapper( self, is_logged_in, use_staff_user, client, user_client, staff_client ): """ diff --git a/unified_ecommerce/utils_test.py b/unified_ecommerce/utils_test.py index 0c9ef5db..69cc726d 100644 --- a/unified_ecommerce/utils_test.py +++ b/unified_ecommerce/utils_test.py @@ -102,7 +102,7 @@ def test_markdown_to_plain_text(): assert html_to_plain_text(normal_text) == normal_text -@pytest.mark.django_db() +@pytest.mark.django_db @pytest.mark.parametrize("chunk_size", [2, 3, 5, 7, 9, 10]) def test_prefetched_iterator(chunk_size): """