From ddc86477a96b81ed1cc007a6925b3fa401cf45fa Mon Sep 17 00:00:00 2001 From: Gareth Paul Jones Date: Sun, 7 Jun 2020 12:08:36 -0700 Subject: [PATCH 1/3] fix pendulum import error --- orator/connectors/sqlite_connector.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orator/connectors/sqlite_connector.py b/orator/connectors/sqlite_connector.py index 2b165f55..eaef07b2 100644 --- a/orator/connectors/sqlite_connector.py +++ b/orator/connectors/sqlite_connector.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- -from pendulum import Pendulum, Date +import pendulum try: import sqlite3 from sqlite3 import register_adapter - register_adapter(Pendulum, lambda val: val.isoformat(" ")) - register_adapter(Date, lambda val: val.isoformat()) + register_adapter(pendulum, lambda val: val.isoformat(" ")) + register_adapter(pendulum.Date, lambda val: val.isoformat()) except ImportError: sqlite3 = None From 2fe8f6620cd314d0ad34a8b766ee3f18c6194175 Mon Sep 17 00:00:00 2001 From: Gareth Paul Jones Date: Sun, 7 Jun 2020 12:09:45 -0700 Subject: [PATCH 2/3] fix pendulum import --- orator/connectors/mysql_connector.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/orator/connectors/mysql_connector.py b/orator/connectors/mysql_connector.py index 858493d7..cb437bc1 100644 --- a/orator/connectors/mysql_connector.py +++ b/orator/connectors/mysql_connector.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -import re -from pendulum import Pendulum, Date +import re, pendulum try: import MySQLdb as mysql @@ -9,8 +8,8 @@ # Fix for understanding Pendulum object import MySQLdb.converters - MySQLdb.converters.conversions[Pendulum] = MySQLdb.converters.DateTime2literal - MySQLdb.converters.conversions[Date] = MySQLdb.converters.Thing2Literal + MySQLdb.converters.conversions[pendulum] = MySQLdb.converters.DateTime2literal + MySQLdb.converters.conversions[pendulum.Date] = MySQLdb.converters.Thing2Literal from MySQLdb.cursors import DictCursor as cursor_class From 8cba6becd5c3729495eae75b6b6e4a3e8a906701 Mon Sep 17 00:00:00 2001 From: Gareth Paul Jones Date: Sun, 7 Jun 2020 12:15:06 -0700 Subject: [PATCH 3/3] fix tests from Pendulum to pendulum --- tests/orm/test_model.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/orm/test_model.py b/tests/orm/test_model.py index d81abaab..8f24d2b2 100644 --- a/tests/orm/test_model.py +++ b/tests/orm/test_model.py @@ -4,7 +4,7 @@ import hashlib import time import datetime -from pendulum import Pendulum +import pendulum from flexmock import flexmock, flexmock_teardown from .. import OratorTestCase, mock from ..utils import MockModel, MockQueryBuilder, MockConnection, MockProcessor @@ -348,8 +348,8 @@ def test_timestamps_are_returned_as_objects(self): {"created_at": "2015-03-24", "updated_at": "2015-03-24"} ) - self.assertIsInstance(model.created_at, Pendulum) - self.assertIsInstance(model.updated_at, Pendulum) + self.assertIsInstance(model.created_at, pendulum) + self.assertIsInstance(model.updated_at, pendulum) def test_timestamps_are_returned_as_objects_from_timestamps_and_datetime(self): model = Model() @@ -357,8 +357,8 @@ def test_timestamps_are_returned_as_objects_from_timestamps_and_datetime(self): {"created_at": datetime.datetime.utcnow(), "updated_at": time.time()} ) - self.assertIsInstance(model.created_at, Pendulum) - self.assertIsInstance(model.updated_at, Pendulum) + self.assertIsInstance(model.created_at, pendulum) + self.assertIsInstance(model.updated_at, pendulum) def test_timestamps_are_returned_as_objects_on_create(self): model = Model() @@ -371,8 +371,8 @@ def test_timestamps_are_returned_as_objects_on_create(self): instance = model.new_instance(timestamps) - self.assertIsInstance(instance.created_at, Pendulum) - self.assertIsInstance(instance.updated_at, Pendulum) + self.assertIsInstance(instance.created_at, pendulum) + self.assertIsInstance(instance.updated_at, pendulum) model.reguard()