summaryrefslogtreecommitdiff
path: root/test/engine/test_parseconnect.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-04-24 13:00:30 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-04-24 13:00:30 -0400
commit71c00115747d2fb13423b0b18e728b402f117528 (patch)
tree64362d2cab5db6af78b45c0304ad98e1c0ab5a0f /test/engine/test_parseconnect.py
parent998c66fa8b1997453c793da5faa7d4cc436739b2 (diff)
downloadsqlalchemy-71c00115747d2fb13423b0b18e728b402f117528.tar.gz
- [feature] Added a new system
for registration of new dialects in-process without using an entrypoint. See the docs for "Registering New Dialects". [ticket:2462]
Diffstat (limited to 'test/engine/test_parseconnect.py')
-rw-r--r--test/engine/test_parseconnect.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py
index 032639557..dcb149be8 100644
--- a/test/engine/test_parseconnect.py
+++ b/test/engine/test_parseconnect.py
@@ -4,6 +4,7 @@ import StringIO
import sqlalchemy.engine.url as url
from sqlalchemy import create_engine, engine_from_config, exc, pool
from sqlalchemy.engine import _coerce_config
+from sqlalchemy.engine.default import DefaultDialect
import sqlalchemy as tsa
from test.lib import fixtures, testing
@@ -315,6 +316,44 @@ pool_timeout=10
_initialize=False,
)
+class TestRegNewDBAPI(fixtures.TestBase):
+ def test_register_base(self):
+ from sqlalchemy.dialects import registry
+ registry.register("mockdialect", __name__, "MockDialect")
+
+ e = create_engine("mockdialect://")
+ assert isinstance(e.dialect, MockDialect)
+
+ def test_register_dotted(self):
+ from sqlalchemy.dialects import registry
+ registry.register("mockdialect.foob", __name__, "MockDialect")
+
+ e = create_engine("mockdialect+foob://")
+ assert isinstance(e.dialect, MockDialect)
+
+ def test_register_legacy(self):
+ from sqlalchemy.dialects import registry
+ tokens = __name__.split(".")
+
+ global dialect
+ dialect = MockDialect
+ registry.register("mockdialect.foob", ".".join(tokens[0:-1]), tokens[-1])
+
+ e = create_engine("mockdialect+foob://")
+ assert isinstance(e.dialect, MockDialect)
+
+ def test_register_per_dbapi(self):
+ from sqlalchemy.dialects import registry
+ registry.register("mysql.my_mock_dialect", __name__, "MockDialect")
+
+ e = create_engine("mysql+my_mock_dialect://")
+ assert isinstance(e.dialect, MockDialect)
+
+class MockDialect(DefaultDialect):
+ @classmethod
+ def dbapi(cls, **kw):
+ return MockDBAPI()
+
class MockDBAPI(object):
version_info = sqlite_version_info = 99, 9, 9
sqlite_version = '99.9.9'