Skip to content

override_settings not working #6030

@csdenboer

Description

@csdenboer

In my unit tests, I'm facing troubles with requests being denied because of throttle rates. By setting DEFAULT_THROTTLE_CLASSES to (), requests are no longer throttled. However, I only want to do this for unit tests, so I tried to use override_settings to override the DEFAULT_THROTTLE_CLASSES setting.

    def test_login_invalid_email(self):
        with override_settings(REST_FRAMEWORK={**settings.REST_FRAMEWORK, 'DEFAULT_THROTTLE_CLASSES': ()}):
            data = {'email': 'invalid@email', 'password': self.data['password']}
            response = self.client.post(reverse('login'), data, secure=True)
            self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

This does not work; I'm still getting 429's. How can I get this working?

Note: I'm using latest version of django-rest-framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions