Skip to content

Conversation

@tkrtmy
Copy link
Contributor

@tkrtmy tkrtmy commented Jan 5, 2024

When writing unit tests, I'd like to use app.dependency_overrides to replace RateLimiter with a stub.

pseudo code

def test_hoge():
  app: FastAPI
...
  app.dependency_overrides[RateLimiter(times=60, minutes=1)] = lambda: True

related to:


if __name__ == "__main__":
uvicorn.run("main:app", debug=True, reload=True)
uvicorn.run("main:app", reload=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uvicorn.run("main:app", debug=True, reload=True)
TypeError: run() got an unexpected keyword argument 'debug'


def __eq__(self, other: object) -> bool:
if isinstance(other, RateLimiter):
return (self.times, self.milliseconds) == (other.times, other.milliseconds)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify equivalence in a simple way.

@tkrtmy
Copy link
Contributor Author

tkrtmy commented Jan 8, 2024

@long2ice I would like you to confirm this change 🙏
And I hope you will release a newer version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant