Skip to content

Commit 80cf744

Browse files
committed
Be lenient on sqlite3 features on CPython
1 parent 2496398 commit 80cf744

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_sqlite3.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ def test_basic_functionality():
5252

5353

5454
def test_fts5_works():
55+
# we explicitly enable those features below, but on CPython they might not
56+
# be available if using some system libsqlite that doesn't have them
5557
import sqlite3
5658
conn = sqlite3.connect(':memory:')
57-
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts5(column1, column2)")
58-
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts4(column1, column2)")
59-
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts3(column1, column2)")
60-
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING rtree(column1, column2)")
61-
sqpi = next(conn.execute("SELECT pi()"))[0]
62-
assert 3.14 == float(f'{sqpi:.2f}'), sqpi
59+
try:
60+
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts5(column1, column2)")
61+
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts4(column1, column2)")
62+
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING fts3(column1, column2)")
63+
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS your_table USING rtree(column1, column2)")
64+
sqpi = next(conn.execute("SELECT pi()"))[0]
65+
assert 3.14 == float(f'{sqpi:.2f}'), sqpi
66+
except sqlite3.OperationalError:
67+
import sys
68+
assert sys.implementation.name != "graalpy"
6369
conn.close()

0 commit comments

Comments
 (0)