- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
TestClient accepts backend and backend_options as arguments #1210
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
Changes from 2 commits
a90343b
              3d97f8f
              a43e548
              75526c1
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -381,13 +381,11 @@ def receive_json(self, mode: str = "text") -> typing.Any: | |
| 
     | 
||
| class TestClient(requests.Session): | ||
| __test__ = False # For pytest to not discover this up. | ||
| 
     | 
||
| #: These options are passed to `anyio.start_blocking_portal()` | ||
| #: These are the default options for the constructor arguments | ||
| async_backend: typing.Dict[str, typing.Any] = { | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this class-level declaration still? Class vars always confuse me, but this means somebody can do: TestClient.async_backend["backend"] = "trio"to default all future  I know removing this would be slightly changing the API, however in the code examples we gave we only modified instance attributes and that usage should stay the same. What's your thinking around this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed it in my followup PR: #1211  | 
||
| "backend": "asyncio", | ||
| "backend_options": {}, | ||
| } | ||
| 
     | 
||
| task: "Future[None]" | ||
| 
     | 
||
| def __init__( | ||
| 
        
          
        
         | 
    @@ -396,8 +394,14 @@ def __init__( | |
| base_url: str = "http://testserver", | ||
| raise_server_exceptions: bool = True, | ||
| root_path: str = "", | ||
| backend: typing.Optional[str] = None, | ||
| backend_options: typing.Optional[typing.Dict[str, typing.Any]] = None, | ||
| ) -> None: | ||
| super().__init__() | ||
| self.async_backend = { | ||
| "backend": backend or self.async_backend["backend"], | ||
| "backend_options": backend_options or self.async_backend["backend_options"], | ||
| } | ||
| if _is_asgi3(app): | ||
| app = typing.cast(ASGI3App, app) | ||
| asgi_app = app | ||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.