Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make 3.10 sqlite3 tests run #94998

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

Closed
terryjreedy opened this issue Jul 19, 2022 · 7 comments
Closed

Make 3.10 sqlite3 tests run #94998

terryjreedy opened this issue Jul 19, 2022 · 7 comments
Assignees
Labels
3.10 only security fixes topic-sqlite3 type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

On my Windows 10, after fresh repository update and debug build, 3.10 sqlite3 tests do not run.
(3.11 and 3.12 are fine.) In 3.10, test_sqlite/ only contains test_dbapi.py

python -m test test_sqlite3 is OK after no tests run. (I though we made this an error.)
python -m test.test_sqlite3 fails because test_sqlite3/ is missing __main__.py, as well as __init__.py

In 3.11, test_sqlite3.__main__.py is

from test.test_sqlite3 import load_tests  # Needed for the "load tests" protocol.
import unittest

if __name__ == "__main__":
    unittest.main()

The comment seems not needed. The other 3.10 test.test_x directories all run and have variations of this. Some have from . import load_tests. Some have unittest.main('test.test_x') instead of a load_tests import. Most omit the redundant if-clause.

After adding __main__.py, tests still do not run because __init__.py is needed. I may try to do a PR tomorrow.

@terryjreedy terryjreedy added type-bug An unexpected behavior, bug, or error 3.10 only security fixes topic-sqlite3 labels Jul 19, 2022
@erlend-aasland erlend-aasland self-assigned this Jul 19, 2022
@terryjreedy
Copy link
Member Author

terryjreedy commented Jul 19, 2022

I copied 3.11 test_sqlite3/__init__.py into the 3.10 directory.
With python -m test -v test_sqlite3, the loader runs but fails on line 47
def cx_limit(cx, category=sqlite.SQLITE_LIMIT_SQL_LENGTH, limit=128):
with an attribute error for SQLITE_LIMIT_SQL_LENGTH.

With the function commented out, python crashes with Windows fatal exception: access violation in test_connection_bad_reinit at line 572 , self.assertRaisesRegex(...) line 572. Before that, multiple tests failed, far more than need the commented out function.

(Reminder to self: changes on branch sql310.)

terryjreedy added a commit to terryjreedy/cpython that referenced this issue Jul 19, 2022
Add __init__ and __main__ to test_sqlite3 directory.
In test_dbapi, comment out cx_limit, line 42.
Add 'verbosity=2' to unittest.main().
@erlend-aasland
Copy link
Contributor

On my Windows 10, after fresh repository update and debug build, 3.10 sqlite3 tests do not run. (3.11 and 3.12 are fine.) In 3.10, test_sqlite/ only contains test_dbapi.py

There is no Lib/test/test_sqlite/ directory in the 3.10 branch. However, due to a backport failure (2229d34), there is a partial Lib/test/test_sqlite3/ directory. This needs to be removed from the 3.10 branch; the sqlite3 tests are found in Lib/sqlite3/test/ for the 3.10 branch and older.

In 3.11, test_sqlite3.__main__.py is [...]

The comment seems not needed.

It was added by Brett's request. I'd like to keep it there, as it explains the otherwise apparently unused import.

Most omit the redundant if-clause.

Tests can be run directly (./<test-path> on *nix) or via ./python -m test <test-name>, so please leave it as it is; it is needed.

@erlend-aasland
Copy link
Contributor

FTR, sqlite3 tests run as they should in 3.10:

$ ./python.exe -m test test_sqlite -v | wc -l 
     369

erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Jul 19, 2022
…lite3 directory

The directory was incorrectly partially backported in commit 2229d34
(See pythongh-93801)
@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jul 19, 2022

Sorry, this may not be obvious, but the sqlite3 tests were moved in 3.11. For 3.10 and older, they all lived in Lib/sqlite3/test, and were invoked via Lib/test/test_sqlite.py (for example, python -m test test_sqlite). For 3.11, they live in Lib/test/test_sqlite3/, and they are now invoked using the correct module name (python -m test test_sqlite3).

Perhaps we should add an entry to the 3.11 What's New.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jul 19, 2022

Fixed with gh-95016; thanks for the report!

@terryjreedy
Copy link
Member Author

I wondered whether deleting test_sqlite3/ might be a reasonable alternative. But was not aware that it was a partial duplicate.

The purpose of conditionalizing unittest.main() in x.py is to not call it when x is imported. But main.py is normally only run with __name__ '__main__', when the call is wanted. python -m test test_xyz' only *imports* test_xyz and when it is a directory, only runs its init, not main. This is why the current omission in most such 3.10 main`s is not a problem. (But I have no intention of changing anything.)

I think all the test directory movements should be mentioned in the corresponding What's New.

@erlend-aasland
Copy link
Contributor

Yeah, I think you're right about the __main__ conditional; it is redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes topic-sqlite3 type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants