pytest-dev / pytest-dev/pytest-django

Impossible to bypass THROTTLE - Django REST

Open
#1,067 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

I'm trying to test throttling in some test cases with live_server and it's a pain in the butt.

After spending way too much time trying to override LiveServer I figured it might be simpler to just disable throttling for most test cases with an autouse fixture like below.

@pytest.fixture(autouse=True)
def bypass_throttle(settings):
    settings.REST_FRAMEWORK["DEFAULT_THROTTLE_CLASSES"] = []
    settings.REST_FRAMEWORK["DEFAULT_THROTTLE_RATES"] = {}
    yield

However this again has no effect. Is there any reliable way to do this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the autouse bypass_throttle fixture with live_server, then inspect how the project and Django REST Framework load throttle settings during tests. Done means identifying a reliable way to disable throttling for most test cases while preserving tests that explicitly exercise throttling.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.