summaryrefslogtreecommitdiff
path: root/tests/backends/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'tests/backends/sqlite')
-rw-r--r--tests/backends/sqlite/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py
index c82ed1667d..86723a72d2 100644
--- a/tests/backends/sqlite/tests.py
+++ b/tests/backends/sqlite/tests.py
@@ -59,6 +59,22 @@ class Tests(TestCase):
creation = DatabaseWrapper(settings_dict).creation
self.assertEqual(creation._get_test_db_name(), creation.connection.settings_dict['TEST']['NAME'])
+ def test_regexp_function(self):
+ tests = (
+ ('test', r'[0-9]+', False),
+ ('test', r'[a-z]+', True),
+ ('test', None, None),
+ (None, r'[a-z]+', None),
+ (None, None, None),
+ )
+ for string, pattern, expected in tests:
+ with self.subTest((string, pattern)):
+ with connection.cursor() as cursor:
+ cursor.execute('SELECT %s REGEXP %s', [string, pattern])
+ value = cursor.fetchone()[0]
+ value = bool(value) if value in {0, 1} else value
+ self.assertIs(value, expected)
+
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
@isolate_apps('backends')