summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-30 18:35:12 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-30 18:35:12 -0400
commitb38a76cd1d47cd6b8f1abef30ad7c3aeaa27d537 (patch)
tree7af1dba9e242c77a248cb2194434aa9bf3ca49b7 /test/dialect/postgresql
parent715d6cf3d10a71acd7726b7e00c3ff40b4559bc7 (diff)
downloadsqlalchemy-b38a76cd1d47cd6b8f1abef30ad7c3aeaa27d537.tar.gz
- replace most explicitly-named test objects called "Mock..." with
actual mock objects from the mock library. I'd like to use mock for new tests so we might as well use it in obvious places. - use unittest.mock in py3.3 - changelog - add a note to README.unittests - add tests_require in setup.py - have tests import from sqlalchemy.testing.mock - apply usage of mock to one of the event tests. we can be using this approach all over the place.
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_dialect.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index 86ce91dc9..1fc239cb7 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -16,6 +16,7 @@ from sqlalchemy import exc, schema
from sqlalchemy.dialects.postgresql import base as postgresql
import logging
import logging.handlers
+from sqlalchemy.testing.mock import Mock
class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
@@ -37,18 +38,12 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
'The JDBC driver handles the version parsing')
def test_version_parsing(self):
-
- class MockConn(object):
-
- def __init__(self, res):
- self.res = res
-
- def execute(self, str):
- return self
-
- def scalar(self):
- return self.res
-
+ def mock_conn(res):
+ return Mock(
+ execute=Mock(
+ return_value=Mock(scalar=Mock(return_value=res))
+ )
+ )
for string, version in \
[('PostgreSQL 8.3.8 on i686-redhat-linux-gnu, compiled by '
@@ -59,7 +54,7 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
('EnterpriseDB 9.1.2.2 on x86_64-unknown-linux-gnu, '
'compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50), '
'64-bit', (9, 1, 2))]:
- eq_(testing.db.dialect._get_server_version_info(MockConn(string)),
+ eq_(testing.db.dialect._get_server_version_info(mock_conn(string)),
version)
@testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature')