Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashable & equalable #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

hashable & equalable #49

wants to merge 2 commits into from

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:

@@ -54,4 +54,4 @@ async def websocket_endpoint(websocket: WebSocket):


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