From 0f86ed7f4d9e19ff452ebb725897ad443c039a9d Mon Sep 17 00:00:00 2001 From: Dan McKinley Date: Fri, 14 Jun 2024 10:11:55 -0700 Subject: [PATCH] fixes warning about sqlite3 conversion deprecation in python 3.12 --- tests/test_pugsql.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_pugsql.py b/tests/test_pugsql.py index 048be55..f4b7642 100644 --- a/tests/test_pugsql.py +++ b/tests/test_pugsql.py @@ -1,9 +1,11 @@ -import pugsql -from pugsql import exceptions -import pytest import threading from unittest import TestCase +import pytest + +import pugsql +from pugsql import exceptions + def test_module(): assert pugsql.module('tests/sql').sqlpaths == {'tests/sql',} @@ -174,10 +176,16 @@ def test_pass_connect_args(self): import sqlite3 from datetime import datetime + def _convert_timestamp(ts): + return datetime.strptime(ts.decode("utf-8"), "%Y-%m-%d %H:%M:%S") + sqlite3.register_converter('TIMESTAMP', _convert_timestamp) + self.fixtures.disconnect() self.fixtures.connect( 'sqlite:///./tests/data/fixtures.sqlite3', - connect_args={'detect_types': sqlite3.PARSE_DECLTYPES}) + connect_args={ + 'detect_types': sqlite3.PARSE_DECLTYPES, + }) date = self.fixtures.find_date(id=1) self.assertIs(datetime, type(date['created']))