mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
TextIOBase moved to tests compat imports
This commit is contained in:
parent
d90ad8627d
commit
aaba4dcf87
|
@ -31,17 +31,11 @@ from subprocess import Popen, PIPE
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
from .testutils import skip_copy_if_green
|
from .testutils import skip_copy_if_green, TextIOBase
|
||||||
from .testconfig import dsn
|
from .testconfig import dsn
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
class MinimalRead(TextIOBase):
|
||||||
_base = object
|
|
||||||
else:
|
|
||||||
from io import TextIOBase as _base
|
|
||||||
|
|
||||||
|
|
||||||
class MinimalRead(_base):
|
|
||||||
"""A file wrapper exposing the minimal interface to copy from."""
|
"""A file wrapper exposing the minimal interface to copy from."""
|
||||||
def __init__(self, f):
|
def __init__(self, f):
|
||||||
self.f = f
|
self.f = f
|
||||||
|
@ -53,7 +47,7 @@ class MinimalRead(_base):
|
||||||
return self.f.readline()
|
return self.f.readline()
|
||||||
|
|
||||||
|
|
||||||
class MinimalWrite(_base):
|
class MinimalWrite(TextIOBase):
|
||||||
"""A file wrapper exposing the minimal interface to copy to."""
|
"""A file wrapper exposing the minimal interface to copy to."""
|
||||||
def __init__(self, f):
|
def __init__(self, f):
|
||||||
self.f = f
|
self.f = f
|
||||||
|
@ -351,7 +345,7 @@ conn.close()
|
||||||
self.assertEqual(0, proc.returncode)
|
self.assertEqual(0, proc.returncode)
|
||||||
|
|
||||||
def test_copy_from_propagate_error(self):
|
def test_copy_from_propagate_error(self):
|
||||||
class BrokenRead(_base):
|
class BrokenRead(TextIOBase):
|
||||||
def read(self, size):
|
def read(self, size):
|
||||||
return 1 / 0
|
return 1 / 0
|
||||||
|
|
||||||
|
@ -368,7 +362,7 @@ conn.close()
|
||||||
self.assert_('ZeroDivisionError' in str(e))
|
self.assert_('ZeroDivisionError' in str(e))
|
||||||
|
|
||||||
def test_copy_to_propagate_error(self):
|
def test_copy_to_propagate_error(self):
|
||||||
class BrokenWrite(_base):
|
class BrokenWrite(TextIOBase):
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
return 1 / 0
|
return 1 / 0
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,15 @@ from .testconfig import green
|
||||||
if sys.version_info[0] == 2:
|
if sys.version_info[0] == 2:
|
||||||
# Python 2
|
# Python 2
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
TextIOBase = object
|
||||||
long = long
|
long = long
|
||||||
reload = reload
|
reload = reload
|
||||||
unichr = unichr
|
unichr = unichr
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Python 3
|
# Python 3
|
||||||
from io import StringIO # noqa
|
from io import StringIO # noqa
|
||||||
|
from io import TextIOBase # noqa
|
||||||
from importlib import reload # noqa
|
from importlib import reload # noqa
|
||||||
long = int
|
long = int
|
||||||
unichr = chr
|
unichr = chr
|
||||||
|
|
Loading…
Reference in New Issue
Block a user