summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-05-04 15:57:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-05-04 15:57:03 -0400
commit021b5143e65368bb36889dda03e5a4853621ce29 (patch)
tree0c49723a9495d5997838f7a78805eaf6cf3744f4
parentef629e7b3d8fcac170be36eab45c925ce3582df9 (diff)
downloadsqlalchemy-021b5143e65368bb36889dda03e5a4853621ce29.tar.gz
that's all of engine
-rw-r--r--lib/sqlalchemy/engine/reflection.py8
-rw-r--r--lib/sqlalchemy/util/compat.py6
-rw-r--r--test/engine/test_parseconnect.py7
-rw-r--r--test/engine/test_reflection.py14
4 files changed, 23 insertions, 12 deletions
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py
index cf4a1d532..4b2987851 100644
--- a/lib/sqlalchemy/engine/reflection.py
+++ b/lib/sqlalchemy/engine/reflection.py
@@ -41,8 +41,12 @@ def cache(fn, self, con, *args, **kw):
return fn(self, con, *args, **kw)
key = (
fn.__name__,
- tuple(a for a in args if isinstance(a, str)),
- tuple((k, v) for k, v in kw.items() if isinstance(v, (str, int, float)))
+ tuple(a for a in args if isinstance(a, util.string_types)),
+ tuple((k, v) for k, v in kw.items() if
+ isinstance(v,
+ util.string_types + util.int_types + (float, )
+ )
+ )
)
ret = info_cache.get(key)
if ret is None:
diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py
index 94b35f019..06bcd30dd 100644
--- a/lib/sqlalchemy/util/compat.py
+++ b/lib/sqlalchemy/util/compat.py
@@ -37,6 +37,9 @@ if py3k:
from inspect import getfullargspec as inspect_getfullargspec
from urllib.parse import quote_plus, unquote_plus, parse_qsl
+ import configparser
+ from io import StringIO
+
string_types = str,
binary_type = bytes
text_type = str
@@ -74,6 +77,9 @@ else:
from inspect import getargspec as inspect_getfullargspec
from urllib import quote_plus, unquote_plus
from urlparse import parse_qsl
+ import ConfigParser as configparser
+ from StringIO import StringIO
+
string_types = basestring,
binary_type = str
text_type = unicode
diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py
index 3d99fd509..73bdc76c4 100644
--- a/test/engine/test_parseconnect.py
+++ b/test/engine/test_parseconnect.py
@@ -1,6 +1,5 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message, eq_
-import configparser
-import io
+from sqlalchemy.testing import assert_raises, eq_
+from sqlalchemy.util.compat import configparser, StringIO
import sqlalchemy.engine.url as url
from sqlalchemy import create_engine, engine_from_config, exc, pool
from sqlalchemy.engine.util import _coerce_config
@@ -104,7 +103,7 @@ pool_threadlocal=1
pool_timeout=10
"""
ini = configparser.ConfigParser()
- ini.readfp(io.StringIO(raw))
+ ini.readfp(StringIO(raw))
expected = {
'url': 'postgresql://scott:tiger@somehost/test?fooz=somevalue',
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py
index d8256f2b0..a562ef73b 100644
--- a/test/engine/test_reflection.py
+++ b/test/engine/test_reflection.py
@@ -7,6 +7,8 @@ from sqlalchemy.testing import ComparesTables, \
from sqlalchemy.testing.schema import Table, Column
from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
from sqlalchemy import testing
+from sqlalchemy.util import ue
+
metadata, users = None, None
@@ -1042,16 +1044,16 @@ class UnicodeReflectionTest(fixtures.TestBase):
('plain', 'col_plain', 'ix_plain')
])
no_has_table = [
- ('no_has_table_1', 'col_Unit\u00e9ble', 'ix_Unit\u00e9ble'),
- ('no_has_table_2', 'col_\u6e2c\u8a66', 'ix_\u6e2c\u8a66'),
+ ('no_has_table_1', ue('col_Unit\u00e9ble'), ue('ix_Unit\u00e9ble')),
+ ('no_has_table_2', ue('col_\u6e2c\u8a66'), ue('ix_\u6e2c\u8a66')),
]
no_case_sensitivity = [
- ('\u6e2c\u8a66', 'col_\u6e2c\u8a66', 'ix_\u6e2c\u8a66'),
- ('unit\u00e9ble', 'col_unit\u00e9ble', 'ix_unit\u00e9ble'),
+ (ue('\u6e2c\u8a66'), ue('col_\u6e2c\u8a66'), ue('ix_\u6e2c\u8a66')),
+ (ue('unit\u00e9ble'), ue('col_unit\u00e9ble'), ue('ix_unit\u00e9ble')),
]
full = [
- ('Unit\u00e9ble', 'col_Unit\u00e9ble', 'ix_Unit\u00e9ble'),
- ('\u6e2c\u8a66', 'col_\u6e2c\u8a66', 'ix_\u6e2c\u8a66'),
+ (ue('Unit\u00e9ble'), ue('col_Unit\u00e9ble'), ue('ix_Unit\u00e9ble')),
+ (ue('\u6e2c\u8a66'), ue('col_\u6e2c\u8a66'), ue('ix_\u6e2c\u8a66')),
]
# as you can see, our options for this kind of thing