-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3064 Add typings to test package #844
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 all commits
8627451
7ed5731
a385dff
d435dad
6009bf6
699e696
3f651f0
6247b9a
44607b7
d1b77b7
3c6ada0
887d804
d63bcc3
2b3796e
937a366
7ca474f
1f3a2aa
363c947
d12570e
1920c47
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 |
---|---|---|
|
@@ -16,9 +16,8 @@ | |
|
||
import errno | ||
import select | ||
import socket | ||
import sys | ||
from typing import Any, Optional | ||
from typing import Any, Optional, Union | ||
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. Union is now unused. 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. Fixed |
||
|
||
# PYTHON-2320: Jython does not fully support poll on SSL sockets, | ||
# https://bugs.jython.org/issue2900 | ||
|
@@ -43,7 +42,7 @@ def __init__(self) -> None: | |
else: | ||
self._poller = None | ||
|
||
def select(self, sock: Any, read: bool = False, write: bool = False, timeout: int = 0) -> bool: | ||
def select(self, sock: Any, read: bool = False, write: bool = False, timeout: Optional[float] = 0) -> bool: | ||
"""Select for reads or writes with a timeout in seconds (or None). | ||
|
||
Returns True if the socket is readable/writable, False on timeout. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
|
||
class TestAuthAWS(unittest.TestCase): | ||
uri: str | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
class TestResetAndRequestCheck(unittest.TestCase): | ||
def __init__(self, *args, **kwargs): | ||
super(TestResetAndRequestCheck, self).__init__(*args, **kwargs) | ||
self.ismaster_time = 0 | ||
self.ismaster_time = 0.0 | ||
self.client = None | ||
self.server = None | ||
|
||
|
@@ -45,7 +45,7 @@ def responder(request): | |
kwargs = {'socketTimeoutMS': 100} | ||
# Disable retryable reads when pymongo supports it. | ||
kwargs['retryReads'] = False | ||
self.client = MongoClient(self.server.uri, **kwargs) | ||
self.client = MongoClient(self.server.uri, **kwargs) # type: ignore | ||
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. What's up with the type ignore here? It seems perfectly reasonable to pass 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. Yeah it is a type limitation of mypy, I'll look for/file an issue 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. Found this comment: I'll try 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. Actually, it really is a bug, already reported: python/mypy#8862 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. Created https://jira.mongodb.org/browse/PYTHON-3105 to track this |
||
wait_until(lambda: self.client.nodes, 'connect to standalone') | ||
|
||
def tearDown(self): | ||
|
@@ -56,6 +56,8 @@ def _test_disconnect(self, operation): | |
# Application operation fails. Test that client resets server | ||
# description and does *not* schedule immediate check. | ||
self.setup_server() | ||
assert self.server is not None | ||
assert self.client is not None | ||
|
||
# Network error on application operation. | ||
with self.assertRaises(ConnectionFailure): | ||
|
@@ -81,6 +83,8 @@ def _test_timeout(self, operation): | |
# Application operation times out. Test that client does *not* reset | ||
# server description and does *not* schedule immediate check. | ||
self.setup_server() | ||
assert self.server is not None | ||
assert self.client is not None | ||
|
||
with self.assertRaises(ConnectionFailure): | ||
with going(operation.function, self.client): | ||
|
@@ -91,6 +95,7 @@ def _test_timeout(self, operation): | |
# Server is *not* Unknown. | ||
topology = self.client._topology | ||
server = topology.select_server_by_address(self.server.address, 0) | ||
assert server is not None | ||
self.assertEqual(SERVER_TYPE.Standalone, server.description.server_type) | ||
|
||
after = self.ismaster_time | ||
|
@@ -99,6 +104,8 @@ def _test_timeout(self, operation): | |
def _test_not_master(self, operation): | ||
# Application operation gets a "not master" error. | ||
self.setup_server() | ||
assert self.server is not None | ||
assert self.client is not None | ||
|
||
with self.assertRaises(ConnectionFailure): | ||
with going(operation.function, self.client): | ||
|
@@ -110,6 +117,7 @@ def _test_not_master(self, operation): | |
# Server is rediscovered. | ||
topology = self.client._topology | ||
server = topology.select_server_by_address(self.server.address, 0) | ||
assert server is not None | ||
self.assertEqual(SERVER_TYPE.Standalone, server.description.server_type) | ||
|
||
after = self.ismaster_time | ||
|
Uh oh!
There was an error while loading. Please reload this page.