Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure everything works under CPython 2.6, 2.7, 3.2, 3.3 and PyPy.

  • Loading branch information...
commit 0142e305a2cf6942a58b7b0f9167548f9790ec72 1 parent 944b2c2
@FSX authored
View
36 .travis.yml
@@ -1,20 +1,30 @@
language: python
+
python:
- - "2.7"
- - "3.2"
- - "3.3"
+ - 2.6
+ - 2.7
+ - 3.2
+ - 3.3
+ - pypy
before_script:
- - "psql -c 'CREATE DATABASE momoko_test;' -U postgres"
- - "psql -c 'CREATE EXTENSION hstore;' -U postgres"
+ - psql -c 'CREATE DATABASE momoko_test;' -U postgres
env:
- MOMOKO_TEST_DB="momoko_test"
- MOMOKO_TEST_USER="postgres"
- MOMOKO_TEST_PASSWORD=""
- MOMOKO_TEST_HOST=""
- MOMOKO_TEST_PORT="5432"
- MOMOKO_TEST_HSTORE="0"
+ - MOMOKO_PSYCOPG2_IMPL=psycopg2
+ - MOMOKO_PSYCOPG2_IMPL=psycopg2ct
+ - MOMOKO_PSYCOPG2_IMPL=psycopg2cffi
+
+install: "pip install --use-mirrors tornado ${MOMOKO_PSYCOPG2_IMPL}"
+script: python setup.py test
-install: "pip install -r requirements.txt --use-mirrors"
-script: "python setup.py test"
+matrix:
+ exclude:
+ - python: 3.2
+ env: MOMOKO_PSYCOPG2_IMPL=psycopg2ct
+ - python: 3.2
+ env: MOMOKO_PSYCOPG2_IMPL=psycopg2cffi
+ - python: 3.3
+ env: MOMOKO_PSYCOPG2_IMPL=psycopg2ct
+ - python: 3.3
+ env: MOMOKO_PSYCOPG2_IMPL=psycopg2cffi
View
12 examples/gen_example.py
@@ -17,12 +17,12 @@
import momoko
-db_database = os.environ.get('MOMOKO_TEST_DB', None)
-db_user = os.environ.get('MOMOKO_TEST_USER', None)
-db_password = os.environ.get('MOMOKO_TEST_PASSWORD', None)
-db_host = os.environ.get('MOMOKO_TEST_HOST', None)
-db_port = os.environ.get('MOMOKO_TEST_PORT', None)
-enable_hstore = True if os.environ.get('MOMOKO_TEST_HSTORE', None) == '1' else False
+db_database = os.environ.get('MOMOKO_TEST_DB', 'momoko_test')
+db_user = os.environ.get('MOMOKO_TEST_USER', 'postgres')
+db_password = os.environ.get('MOMOKO_TEST_PASSWORD', '')
+db_host = os.environ.get('MOMOKO_TEST_HOST', '')
+db_port = os.environ.get('MOMOKO_TEST_PORT', 5432)
+enable_hstore = True if os.environ.get('MOMOKO_TEST_HSTORE', False) == '1' else False
dsn = 'dbname=%s user=%s password=%s host=%s port=%s' % (
db_database, db_user, db_password, db_host, db_port)
View
34 momoko/tests.py
@@ -9,12 +9,12 @@
from tornado.testing import AsyncTestCase
-db_database = os.environ.get('MOMOKO_TEST_DB', None)
-db_user = os.environ.get('MOMOKO_TEST_USER', None)
-db_password = os.environ.get('MOMOKO_TEST_PASSWORD', None)
-db_host = os.environ.get('MOMOKO_TEST_HOST', None)
-db_port = os.environ.get('MOMOKO_TEST_PORT', None)
-test_hstore = True if os.environ.get('MOMOKO_TEST_HSTORE', None) == '1' else False
+db_database = os.environ.get('MOMOKO_TEST_DB', 'momoko_test')
+db_user = os.environ.get('MOMOKO_TEST_USER', 'postgres')
+db_password = os.environ.get('MOMOKO_TEST_PASSWORD', '')
+db_host = os.environ.get('MOMOKO_TEST_HOST', '')
+db_port = os.environ.get('MOMOKO_TEST_PORT', 5432)
+test_hstore = True if os.environ.get('MOMOKO_TEST_HSTORE', False) == '1' else False
dsn = 'dbname=%s user=%s password=%s host=%s port=%s' % (
db_database, db_user, db_password, db_host, db_port)
@@ -28,7 +28,7 @@ class BaseTest(AsyncTestCase):
def __init__(self, *args, **kwargs):
self.assert_equal = self.assertEqual
self.assert_raises = self.assertRaises
- self.assert_is_instance = self.assertIsInstance
+ self.assert_is_instance = lambda object, classinfo: self.assertTrue(isinstance(object, classinfo))
super(BaseTest, self).__init__(*args, **kwargs)
def setUp(self):
@@ -132,15 +132,15 @@ def test_large_query(self):
cursor = self.wait_for_result()
self.assert_equal(cursor.fetchone(), (5,))
- @unittest.skipIf(not test_hstore, 'hstore is disabled')
- def test_hstore(self):
- self.db.execute('SELECT \'a=>b, c=>d\'::hstore;', callback=self.stop_callback)
- cursor = self.wait_for_result()
- self.assert_equal(cursor.fetchall(), [({'a': 'b', 'c': 'd'},)])
+ if test_hstore:
+ def test_hstore(self):
+ self.db.execute('SELECT \'a=>b, c=>d\'::hstore;', callback=self.stop_callback)
+ cursor = self.wait_for_result()
+ self.assert_equal(cursor.fetchall(), [({'a': 'b', 'c': 'd'},)])
- self.db.execute('SELECT %s;', ({'e': 'f', 'g': 'h'},), callback=self.stop_callback)
- cursor = self.wait_for_result()
- self.assert_equal(cursor.fetchall(), [({'e': 'f', 'g': 'h'},)])
+ self.db.execute('SELECT %s;', ({'e': 'f', 'g': 'h'},), callback=self.stop_callback)
+ cursor = self.wait_for_result()
+ self.assert_equal(cursor.fetchall(), [({'e': 'f', 'g': 'h'},)])
def test_callproc(self):
self.db.callproc('unit_test_callproc', (64,), callback=self.stop_callback)
@@ -285,3 +285,7 @@ def func():
self.stop()
self.assert_raises(psycopg2.ProgrammingError, self.run_gen, func)
+
+
+if __name__ == '__main__':
+ unittest.main()
View
2  requirements.txt
@@ -1,2 +0,0 @@
-tornado
-psycopg2
View
30 setup.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+import os
+
# The multiprocessingimport is to prevent the following error
# after all the tests have been executed.
# Error in atexit._run_exitfuncs:
@@ -16,6 +18,27 @@
from distutils.core import setup, Extension, Command
+dependencies = ['tornado']
+psycopg2_impl = os.environ.get('MOMOKO_PSYCOPG2_IMPL', 'psycopg2')
+
+
+if psycopg2_impl == 'psycopg2cffi':
+ print('Using psycopg2cffi')
+ dependencies.append('psycopg2cffi')
+
+ from psycopg2cffi import compat
+ compat.register()
+elif psycopg2_impl == 'psycopg2ct':
+ print('Using psycopg2ct')
+ dependencies.append('psycopg2ct')
+
+ from psycopg2ct import compat
+ compat.register()
+else:
+ print('Using psycopg2')
+ dependencies.append('psycopg2')
+
+
setup(
name='Momoko',
version='1.0.0b2',
@@ -26,11 +49,8 @@
url='http://momoko.61924.nl/',
packages=['momoko'],
license='MIT',
- test_suite = 'momoko.tests',
- install_requires=[
- 'tornado',
- 'psycopg2'
- ],
+ test_suite='momoko.tests',
+ install_requires=dependencies,
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Please sign in to comment.
Something went wrong with that request. Please try again.