Commit 59d4ba9
committed
[py] Remove redundant driver_instance from conftest.py
Currently, the driver lifetime is handled by two global variables:
- `driver_instance`, the actual Selenium API driver.
- `selenium_driver`, the wrapper `conftest.Driver`, which "owns" the
former.
Also, conftest.py could quit the driver from multiple places:
- `Driver.stop_driver` finalizer, used for bidi and xfail tests
- `stop_driver` Session-scope fixture finalizer
- `pytest_exception_interact` to handle exceptions
The last two paths called `driver_instance.quit()` directly but did
not tell `selenium_driver` that the driver had exited. This could
potentially raise `urllib.exception.MaxRetryError`, as
`Driver.stop_driver` would try to send the `quit()` command to an
already destroyed driver service.
For example, this happened rather frequently on WebKit import of
selenium 4.34.2 tests, whenever an exception happened, as we have
enabled the `bidi` flag when calling pytest.
To address this issue, this commit removes the global variable
`driver_instance`, keeping only `selenium_driver` as global,
and routes all teardown paths through `Driver.stop_driver()`.1 parent 83cb4d6 commit 59d4ba9
1 file changed
+18
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
| |||
269 | 268 | | |
270 | 269 | | |
271 | 270 | | |
272 | | - | |
| 271 | + | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | 293 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
303 | 298 | | |
304 | 299 | | |
305 | 300 | | |
306 | 301 | | |
307 | | - | |
308 | 302 | | |
309 | 303 | | |
310 | 304 | | |
| |||
338 | 332 | | |
339 | 333 | | |
340 | 334 | | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | 335 | | |
346 | 336 | | |
347 | 337 | | |
348 | 338 | | |
349 | | - | |
| 339 | + | |
350 | 340 | | |
351 | 341 | | |
| 342 | + | |
| 343 | + | |
352 | 344 | | |
353 | | - | |
| 345 | + | |
354 | 346 | | |
355 | 347 | | |
356 | 348 | | |
357 | 349 | | |
358 | 350 | | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
363 | 355 | | |
364 | 356 | | |
365 | 357 | | |
366 | 358 | | |
367 | 359 | | |
368 | 360 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
373 | 365 | | |
374 | 366 | | |
375 | 367 | | |
| |||
0 commit comments