Commit c2832ae5 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[py3] Alias long to int in pgstore tests

The previous version of handling PY2/PY3 made flake8 complain.
parent 6350e0a482d5
...@@ -20,13 +20,17 @@ ...@@ -20,13 +20,17 @@
import datetime as DT import datetime as DT
from six import PY2 from six import PY3
from logilab.common.testlib import TestCase, unittest_main from logilab.common.testlib import TestCase, unittest_main
from cubicweb.dataimport import pgstore from cubicweb.dataimport import pgstore
from cubicweb.devtools import testlib from cubicweb.devtools import testlib
if PY3:
long = int
class CreateCopyFromBufferTC(TestCase): class CreateCopyFromBufferTC(TestCase):
# test converters # test converters
...@@ -38,8 +42,7 @@ class CreateCopyFromBufferTC(TestCase): ...@@ -38,8 +42,7 @@ class CreateCopyFromBufferTC(TestCase):
def test_convert_number(self): def test_convert_number(self):
cnvt = pgstore._copyfrom_buffer_convert_number cnvt = pgstore._copyfrom_buffer_convert_number
self.assertEqual(u'42', cnvt(42)) self.assertEqual(u'42', cnvt(42))
if PY2: self.assertEqual(u'42', cnvt(long(42)))
self.assertEqual(u'42', cnvt(long(42)))
self.assertEqual(u'42.42', cnvt(42.42)) self.assertEqual(u'42.42', cnvt(42.42))
def test_convert_string(self): def test_convert_string(self):
...@@ -66,10 +69,9 @@ class CreateCopyFromBufferTC(TestCase): ...@@ -66,10 +69,9 @@ class CreateCopyFromBufferTC(TestCase):
# test buffer # test buffer
def test_create_copyfrom_buffer_tuple(self): def test_create_copyfrom_buffer_tuple(self):
l = long if PY2 else int # noqa: E741 data = ((42, long(42), 42.42, u'éléphant', DT.date(666, 1, 13), DT.time(6, 6, 6),
data = ((42, l(42), 42.42, u'éléphant', DT.date(666, 1, 13), DT.time(6, 6, 6),
DT.datetime(666, 6, 13, 6, 6, 6)), DT.datetime(666, 6, 13, 6, 6, 6)),
(6, l(6), 6.6, u'babar', DT.date(2014, 1, 14), DT.time(4, 2, 1), (6, long(6), 6.6, u'babar', DT.date(2014, 1, 14), DT.time(4, 2, 1),
DT.datetime(2014, 1, 1, 0, 0, 0))) DT.datetime(2014, 1, 1, 0, 0, 0)))
results = pgstore._create_copyfrom_buffer(data) results = pgstore._create_copyfrom_buffer(data)
# all columns # all columns
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment