Skip to content

Commit

Permalink
Make tests pass on Python 3.2 and 3.3
Browse files Browse the repository at this point in the history
Drop pysqlite dependency; sqlite3 is in the stdlib since Python 2.5.

Add zope.testing dependency for renormalizers.
  • Loading branch information
mgedmin committed Feb 19, 2013
1 parent 2dc8f02 commit bcd0dc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
18 changes: 5 additions & 13 deletions setup.py
@@ -1,18 +1,7 @@
import sys

import os.path
from setuptools import setup, find_packages

PY3 = sys.version_info[0] == 3

if PY3:
extras_require = {'test': []}
else:
extras_require = {
'test': [
'pysqlite',
]
}
tests_require = ['zope.testing']

setup(
name='zope.sqlalchemy',
Expand All @@ -24,6 +13,7 @@
namespace_packages=['zope'],
test_suite='zope.sqlalchemy.tests.test_suite',
author='Laurence Rowe',

author_email='laurence@lrowe.co.uk',
url='http://pypi.python.org/pypi/zope.sqlalchemy',
description="Minimal Zope/SQLAlchemy transaction integration",
Expand All @@ -39,6 +29,7 @@
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"License :: OSI Approved :: Zope Public License",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand All @@ -49,5 +40,6 @@
'transaction',
'zope.interface>=3.6.0',
],
extras_require=extras_require,
extras_require={'test': tests_require},
tests_require=tests_require,
)
14 changes: 13 additions & 1 deletion src/zope/sqlalchemy/tests.py
Expand Up @@ -41,14 +41,17 @@ def b(s):
return s

import os
import re
import unittest
import transaction
import threading
import time

import sqlalchemy as sa
from sqlalchemy import orm, sql, exc
from zope.sqlalchemy import datamanager as tx
from zope.sqlalchemy import mark_changed
from zope.testing.renormalizing import RENormalizing

TEST_TWOPHASE = bool(os.environ.get('TEST_TWOPHASE'))
TEST_DSN = os.environ.get('TEST_DSN', 'sqlite:///:memory:')
Expand Down Expand Up @@ -602,11 +605,20 @@ def test_suite():
from unittest import TestSuite, makeSuite
import doctest
optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
checker = RENormalizing([
# Python 3 includes module name in exceptions
(re.compile(r"sqlalchemy.orm.exc.DetachedInstanceError:"),
"DetachedInstanceError:"),
# Python 3 drops the u'' prefix on unicode strings
(re.compile(r"u('[^']*')"),
r"\1"),
])
suite = TestSuite()
suite.addTest(makeSuite(ZopeSQLAlchemyTests))
suite.addTest(makeSuite(MultipleEngineTests))
if TEST_DSN.startswith('postgres') or TEST_DSN.startswith('oracle'):
suite.addTest(makeSuite(RetryTests))
suite.addTest(doctest.DocFileSuite('README.txt', optionflags=optionflags, tearDown=tearDownReadMe,
suite.addTest(doctest.DocFileSuite('README.txt', optionflags=optionflags,
checker=checker, tearDown=tearDownReadMe,
globs={'TEST_DSN': TEST_DSN, 'TEST_TWOPHASE': TEST_TWOPHASE}))
return suite
9 changes: 1 addition & 8 deletions tox.ini
Expand Up @@ -4,13 +4,6 @@ envlist =

[testenv]
deps =
zope.testing
commands =
python setup.py test -q

[testenv:py26]
deps = {[testenv]deps}
pysqlite

[testenv:py27]
deps = {[testenv]deps}
pysqlite

0 comments on commit bcd0dc1

Please sign in to comment.