From 9bc8f930af626db56b28d012d4b800a4d9d9e93f Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Thu, 13 Jun 2024 11:41:37 +0100 Subject: [PATCH] fix sqlite tests on certain Python versions --- tests/columns/test_get_sql_value.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/columns/test_get_sql_value.py b/tests/columns/test_get_sql_value.py index 8d30a7111..9a5d1c7d8 100644 --- a/tests/columns/test_get_sql_value.py +++ b/tests/columns/test_get_sql_value.py @@ -35,22 +35,27 @@ def test_time(self): @engines_only("sqlite") class TestArraySQLite(TestCase): + """ + Note, we use ``.replace(" ", "")`` because we serialise arrays using + Python's json library, and there is inconsistency between Python versions + (some output ``["a", "b", "c"]``, and others ``["a","b","c"]``). + """ def test_string(self): self.assertEqual( - Band.name.get_sql_value(["a", "b", "c"]), + Band.name.get_sql_value(["a", "b", "c"]).replace(" ", ""), '\'["a","b","c"]\'', ) def test_int(self): self.assertEqual( - Band.name.get_sql_value([1, 2, 3]), + Band.name.get_sql_value([1, 2, 3]).replace(" ", ""), "'[1,2,3]'", ) def test_nested(self): self.assertEqual( - Band.name.get_sql_value([1, 2, 3, [4, 5, 6]]), + Band.name.get_sql_value([1, 2, 3, [4, 5, 6]]).replace(" ", ""), "'[1,2,3,[4,5,6]]'", )