Deal with E'' strings comparisons in a few other tests

This commit is contained in:
Daniele Varrazzo 2017-07-22 03:11:51 +01:00
parent d619baf000
commit cfa0509d7e

View File

@ -886,7 +886,7 @@ class JsonTestCase(ConnectingTestCase):
curs = self.conn.cursor() curs = self.conn.cursor()
for obj in enumerate(objs): for obj in enumerate(objs):
self.assertEqual(curs.mogrify("%s", (Json(obj),)), self.assertQuotedEqual(curs.mogrify("%s", (Json(obj),)),
psycopg2.extensions.QuotedString(json.dumps(obj)).getquoted()) psycopg2.extensions.QuotedString(json.dumps(obj)).getquoted())
@skip_if_no_json_module @skip_if_no_json_module
@ -904,7 +904,7 @@ class JsonTestCase(ConnectingTestCase):
def dumps(obj): def dumps(obj):
return json.dumps(obj, cls=DecimalEncoder) return json.dumps(obj, cls=DecimalEncoder)
self.assertEqual(curs.mogrify("%s", (Json(obj, dumps=dumps),)), self.assertQuotedEqual(curs.mogrify("%s", (Json(obj, dumps=dumps),)),
b"'123.45'") b"'123.45'")
@skip_if_no_json_module @skip_if_no_json_module
@ -923,7 +923,7 @@ class JsonTestCase(ConnectingTestCase):
curs = self.conn.cursor() curs = self.conn.cursor()
obj = Decimal('123.45') obj = Decimal('123.45')
self.assertEqual(curs.mogrify("%s", (MyJson(obj),)), b"'123.45'") self.assertQuotedEqual(curs.mogrify("%s", (MyJson(obj),)), b"'123.45'")
@skip_if_no_json_module @skip_if_no_json_module
def test_register_on_dict(self): def test_register_on_dict(self):
@ -933,7 +933,8 @@ class JsonTestCase(ConnectingTestCase):
try: try:
curs = self.conn.cursor() curs = self.conn.cursor()
obj = {'a': 123} obj = {'a': 123}
self.assertEqual(curs.mogrify("%s", (obj,)), b"""'{"a": 123}'""") self.assertQuotedEqual(
curs.mogrify("%s", (obj,)), b"""'{"a": 123}'""")
finally: finally:
del psycopg2.extensions.adapters[dict, ext.ISQLQuote] del psycopg2.extensions.adapters[dict, ext.ISQLQuote]