gh-100414: Skip test_dbm_sqlite3 if sqlite3 is unavailable by erlend-aasland · Pull Request #115448 · python/cpython (original) (raw)
LGTM, assuming it fixes the buildbots
We can also do this:
diff --git a/Lib/test/test_dbm_sqlite3.py b/Lib/test/test_dbm_sqlite3.py index 0eda8da4ab..7136b54016 100644 --- a/Lib/test/test_dbm_sqlite3.py +++ b/Lib/test/test_dbm_sqlite3.py @@ -6,9 +6,8 @@ from pathlib import Path from test.support import cpython_only, import_helper, os_helper
- -sqlite3 = import_helper.import_module("sqlite3") dbm_sqlite3 = import_helper.import_module("dbm.sqlite3") +import sqlite3 from dbm.sqlite3 import _normalize_uri
Not much difference between the two :)
The advantage of #115449 is that the test will fail if dbm.sqlite3 is available but sqlite3 is unavailable. That would be pretty weird, but also seems very unlikely to actually happen. The advantage of this PR is that the test will continue to pass no matter which order the imports are in, which is more robust against the test file potentially being refactored in the future.
As I say, very marginal, but I'd probably go for this one!