peewee: test_insert_behavior fails on Python 3.11

While running the tests with Python 3.11.0rc2, I’m seeing this failure.

FAIL: test_insert_behavior (tests.sqlite.TestSqliteReturningConfig.test_insert_behavior)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/carl/development/peewee/tests/sqlite.py", line 2506, in test_insert_behavior
    self.assertEqual(iq.execute(), 2)
AssertionError: 0 != 2

Steps to reproduce on Fedora 36 or 37:

dnf -y install gcc git-core sqlite-devel python3.11-devel
git clone https://github.com/coleifer/peewee.git
cd peewee
python3.11 -m venv py311
. py311/bin/activate
pip install cython
python setup.py install
python setup.py build_ext -i
python runtests.py

EDIT: Forgot to include the exact versions involved. Let me know if others are needed.

F36: python3.11-3.11.0~rc2-1.fc36 sqlite-3.36.0-5.fc36

F37: python3-3.11.0~rc2-1.fc37 sqlite-3.39.2-2.fc37

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (16 by maintainers)

Most upvoted comments

Hope you had a nice adventure, thanks for the links on the debug scripts. I came to the same conclusion as you, which was that we can’t determine the modified rowcount until everything returned by RETURNING has been stepped-through.

I’m going to close this as it seems that, if anything, Python 3.11 has it correct and the test was only passing due to a side-effect (as far as I can tell) of the statement cache. The faulty assertions are removed from our tests.

@carlwgeorge - I’ve put in a very minimal skip directive to get your build passing for now: 49a64bd23591cd96f8ba832646ccac3256481325

I also have pysqlite3 fixed-up and working on master, thanks for sharing those tracebacks with me.

Update: I’ve removed the faulty assertions in light of sqlite3’s behavior checked directly in my comment below - commit 73335396e0336332832e52d4d7272b7d1ed9e794

cc @erlend-aasland if you see this

Thank you, I’ll investigate tomorrow. I only wanted to check because we’ve found a different regression in the 3.11 sqlite3.