mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Added test to verify copysize handling in copy_expert
Not an original psycopg2 bug but present in pure python implementation, e.g. ctypes issue #25 and cffi issue #5. https://github.com/mvantellingen/psycopg2-ctypes/issues/25 https://github.com/chtd/psycopg2cffi/pull/5
This commit is contained in:
parent
a44db81d9b
commit
c796bc2cbd
|
@ -199,6 +199,20 @@ class CopyTests(ConnectingTestCase):
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
self.assertEqual(f.readline().rstrip(), about)
|
self.assertEqual(f.readline().rstrip(), about)
|
||||||
|
|
||||||
|
# same tests with setting size
|
||||||
|
f = io.StringIO()
|
||||||
|
f.write(about)
|
||||||
|
f.seek(0)
|
||||||
|
exp_size = 123
|
||||||
|
# hack here to leave file as is, only check size when reading
|
||||||
|
real_read = f.read
|
||||||
|
def read(_size, f=f, exp_size=exp_size):
|
||||||
|
self.assertEqual(_size, exp_size)
|
||||||
|
return real_read(_size)
|
||||||
|
f.read = read
|
||||||
|
curs.copy_expert('COPY tcopy (data) FROM STDIN', f, size=exp_size)
|
||||||
|
curs.execute("select data from tcopy;")
|
||||||
|
self.assertEqual(curs.fetchone()[0], abin)
|
||||||
|
|
||||||
def _copy_from(self, curs, nrecs, srec, copykw):
|
def _copy_from(self, curs, nrecs, srec, copykw):
|
||||||
f = StringIO()
|
f = StringIO()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user