Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use patch.object instead of assignments
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Gliech <quenting@element.io>
  • Loading branch information
sandhose committed Sep 21, 2022
1 parent 3f1cd16 commit 894dfaa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,12 @@ async def get_requester(*args, **kwargs) -> Requester:
access_token_id=token_id,
)

# Type ignore: mypy doesn't like us assigning to methods.
self.hs.get_auth().get_user_by_req = get_requester # type: ignore[assignment]
self.hs.get_auth().get_user_by_access_token = get_requester # type: ignore[assignment]
self.hs.get_auth().get_access_token_from_request = Mock(return_value=token) # type: ignore[assignment]
get_token = Mock(return_value=token)

auth = self.hs.get_auth()
patch.object(auth, "get_user_by_req", new=get_requester)
patch.object(auth, "get_user_by_access_token", new=get_requester)
patch.object(auth, "get_access_token_from_request", new=get_token)

if self.needs_threadpool:
self.reactor.threadpool = ThreadPool() # type: ignore[assignment]
Expand Down

0 comments on commit 894dfaa

Please sign in to comment.