Skip to content

Commit

Permalink
test for connection property
Browse files Browse the repository at this point in the history
  • Loading branch information
zopyx committed Mar 16, 2008
1 parent 4dd30c4 commit 40de472
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/z3c/sqlalchemy/base.py
Expand Up @@ -99,7 +99,7 @@ def session(self):

@property
def connection(self):
return session.connection()._Connection__connection.connection
return self.session.connection()._Connection__connection.connection

def registerMapper(self, mapper, name):
self._mappers.registerMapper(mapper, name)
Expand Down
7 changes: 6 additions & 1 deletion src/z3c/sqlalchemy/tests/testSQLAlchemy.py
Expand Up @@ -179,13 +179,18 @@ def getModel(md):
user.skills.append(Skill(id=1, name='Zope'))
session.flush()


def testSameSessionWithinSameThread(self):
db = createSAWrapper(self.dsn)
s1 = db.session
s2 = db.session
assert s1 is s2

def testConnectionProperty(self):
db = createSAWrapper(self.dsn)
conn = db.connection
self.assertEqual(hasattr(conn, 'cursor'), True)
self.assertEqual(hasattr(conn, 'execute'), True)


def test_suite():
from unittest import TestSuite, makeSuite
Expand Down

0 comments on commit 40de472

Please sign in to comment.