@@ -44,7 +44,7 @@ def setUp(self):
44
44
self .server = MockupDB ()
45
45
# there are two handshake requests, i believe one is from the monitor, and the other is from the client
46
46
self .monitor_handshake = False
47
- self .handshake_req = None
47
+ self .handshake_req : Optional [ dict ] = None
48
48
49
49
def respond (r ):
50
50
# Only save the very first request from the driver.
@@ -60,7 +60,7 @@ def respond(r):
60
60
self .addCleanup (self .server .stop )
61
61
62
62
def check_metadata_added (
63
- self , add_name : Optional [ str ] , add_version : Optional [str ], add_platform : Optional [str ]
63
+ self , add_name : str , add_version : Optional [str ], add_platform : Optional [str ]
64
64
) -> None :
65
65
client = MongoClient (
66
66
"mongodb://" + self .server .address_string ,
@@ -84,6 +84,7 @@ def check_metadata_added(
84
84
# make sure new metadata is being sent
85
85
self .handshake_req = None
86
86
client .admin .command ("ping" )
87
+ # self.assertIsNotNone(self.handshake_req)
87
88
new_metadata = _get_handshake_driver_info (self .handshake_req )
88
89
89
90
self .assertEqual (
@@ -144,8 +145,10 @@ def test_doesnt_update_established_connections(self):
144
145
add_name , add_version , add_platform = "framework" , "2.0" , "Framework Platform"
145
146
client ._append_metadata (DriverInfo (add_name , add_version , add_platform ))
146
147
# check new data isn't sent
147
- self .handshake_req = None
148
+ self .handshake_req : Optional [ dict ] = None
148
149
client .admin .command ("ping" )
150
+ self .assertIsNotNone (self .handshake_req )
151
+ assert self .handshake_req is not None # so mypy knows that it's not None
149
152
self .assertNotIn ("client" , self .handshake_req )
150
153
self .assertEqual (listener .event_count (ConnectionClosedEvent ), 0 )
151
154
0 commit comments