mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 21:00:33 +03:00
Merge branch 'travis'
This commit is contained in:
commit
f451d35aae
21
.travis.yml
21
.travis.yml
|
@ -1,13 +1,24 @@
|
||||||
|
# Travis CI configuration file for psycopg2
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
sudo: required
|
||||||
language: python
|
language: python
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- 2.6
|
|
||||||
- 2.7
|
- 2.7
|
||||||
|
- 3.6-dev
|
||||||
before_script:
|
- 2.6
|
||||||
- psql -c 'create database psycopg2_test;' -U postgres
|
- 3.5
|
||||||
|
- 3.4
|
||||||
|
- 3.3
|
||||||
|
- 3.2
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- python setup.py install
|
- python setup.py install
|
||||||
|
- sudo scripts/travis_prepare.sh
|
||||||
|
|
||||||
script: make check
|
script:
|
||||||
|
- scripts/travis_test.sh
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
|
@ -44,3 +44,8 @@ For any other resource (source code repository, bug tracker, mailing list)
|
||||||
please check the `project homepage`__.
|
please check the `project homepage`__.
|
||||||
|
|
||||||
.. __: http://initd.org/psycopg/
|
.. __: http://initd.org/psycopg/
|
||||||
|
|
||||||
|
|
||||||
|
.. image:: https://travis-ci.org/psycopg/psycopg2.svg?branch=master
|
||||||
|
:target: https://travis-ci.org/psycopg/psycopg2
|
||||||
|
:alt: Build Status
|
||||||
|
|
43
scripts/travis_prepare.sh
Executable file
43
scripts/travis_prepare.sh
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Prepare the test databases in Travis CI.
|
||||||
|
# The script should be run with sudo.
|
||||||
|
# The script is not idempotent: it assumes the machine in a clean state
|
||||||
|
# and is designed for a sudo-enabled Trusty environment.
|
||||||
|
|
||||||
|
set_param () {
|
||||||
|
# Set a parameter in a postgresql.conf file
|
||||||
|
version=$1
|
||||||
|
param=$2
|
||||||
|
value=$3
|
||||||
|
|
||||||
|
sed -i "s/^\s*#\?\s*$param.*/$param = $value/" \
|
||||||
|
"/etc/postgresql/$version/psycopg/postgresql.conf"
|
||||||
|
}
|
||||||
|
|
||||||
|
create () {
|
||||||
|
version=$1
|
||||||
|
port=$2
|
||||||
|
dbname=psycopg2_test
|
||||||
|
|
||||||
|
pg_createcluster -p $port --start-conf manual $version psycopg
|
||||||
|
set_param "$version" max_prepared_transactions 10
|
||||||
|
pg_ctlcluster "$version" psycopg start
|
||||||
|
|
||||||
|
sudo -u postgres psql -c "create user travis" "port=$port"
|
||||||
|
sudo -u postgres psql -c "create database $dbname" "port=$port"
|
||||||
|
sudo -u postgres psql -c "grant create on database $dbname to travis" "port=$port"
|
||||||
|
sudo -u postgres psql -c "create extension hstore" "port=$port dbname=$dbname"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Would give a permission denied error in the travis build dir
|
||||||
|
cd /
|
||||||
|
|
||||||
|
create 9.6 54396
|
||||||
|
create 9.5 54395
|
||||||
|
create 9.4 54394
|
||||||
|
create 9.3 54393
|
||||||
|
create 9.2 54392
|
28
scripts/travis_test.sh
Executable file
28
scripts/travis_test.sh
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Run the tests in all the databases
|
||||||
|
# The script is designed for a Trusty environment.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
run_test () {
|
||||||
|
version=$1
|
||||||
|
port=$2
|
||||||
|
dbname=psycopg2_test
|
||||||
|
|
||||||
|
printf "\n\nRunning tests against PostgreSQL $version\n\n"
|
||||||
|
export PSYCOPG2_TESTDB=$dbname
|
||||||
|
export PSYCOPG2_TESTDB_PORT=$port
|
||||||
|
export PSYCOPG2_TESTDB_USER=travis
|
||||||
|
make check
|
||||||
|
|
||||||
|
printf "\n\nRunning tests against PostgreSQL $version (green mode)\n\n"
|
||||||
|
export PSYCOPG2_TEST_GREEN=1
|
||||||
|
make check
|
||||||
|
}
|
||||||
|
|
||||||
|
run_test 9.6 54396
|
||||||
|
run_test 9.5 54395
|
||||||
|
run_test 9.4 54394
|
||||||
|
run_test 9.3 54393
|
||||||
|
run_test 9.2 54392
|
|
@ -465,7 +465,7 @@ class MakeDsnTestCase(ConnectingTestCase):
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
d = conn.get_dsn_parameters()
|
d = conn.get_dsn_parameters()
|
||||||
self.assertEqual(d['dbname'], dbname) # the only param we can check reliably
|
self.assertEqual(d['dbname'], dbname) # the only param we can check reliably
|
||||||
self.assertNotIn('password', d)
|
self.assert_('password' not in d, d)
|
||||||
|
|
||||||
|
|
||||||
class IsolationLevelsTestCase(ConnectingTestCase):
|
class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
|
|
|
@ -119,8 +119,8 @@ class ConnectTestCase(unittest.TestCase):
|
||||||
def test_int_port_param(self):
|
def test_int_port_param(self):
|
||||||
psycopg2.connect(database='sony', port=6543)
|
psycopg2.connect(database='sony', port=6543)
|
||||||
dsn = " %s " % self.args[0]
|
dsn = " %s " % self.args[0]
|
||||||
self.assertIn(" dbname=sony ", dsn)
|
self.assert_(" dbname=sony " in dsn, dsn)
|
||||||
self.assertIn(" port=6543 ", dsn)
|
self.assert_(" port=6543 " in dsn, dsn)
|
||||||
|
|
||||||
def test_empty_param(self):
|
def test_empty_param(self):
|
||||||
psycopg2.connect(database='sony', password='')
|
psycopg2.connect(database='sony', password='')
|
||||||
|
|
|
@ -65,11 +65,13 @@ class QuotingTestCase(ConnectingTestCase):
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
data = 'abcd\x01\x00cdefg'
|
data = 'abcd\x01\x00cdefg'
|
||||||
|
|
||||||
with self.assertRaises(ValueError) as e:
|
try:
|
||||||
curs.execute("SELECT %s", (data,))
|
curs.execute("SELECT %s", (data,))
|
||||||
|
except ValueError as e:
|
||||||
self.assertEquals(str(e.exception),
|
self.assertEquals(str(e),
|
||||||
'A string literal cannot contain NUL (0x00) characters.')
|
'A string literal cannot contain NUL (0x00) characters.')
|
||||||
|
else:
|
||||||
|
self.fail("ValueError not raised")
|
||||||
|
|
||||||
def test_binary(self):
|
def test_binary(self):
|
||||||
data = b"""some data with \000\013 binary
|
data = b"""some data with \000\013 binary
|
||||||
|
|
|
@ -35,11 +35,7 @@ from testutils import ConnectingTestCase
|
||||||
|
|
||||||
class ReplicationTestCase(ConnectingTestCase):
|
class ReplicationTestCase(ConnectingTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if not testconfig.repl_dsn:
|
|
||||||
self.skipTest("replication tests disabled by default")
|
|
||||||
|
|
||||||
super(ReplicationTestCase, self).setUp()
|
super(ReplicationTestCase, self).setUp()
|
||||||
|
|
||||||
self.slot = testconfig.repl_slot
|
self.slot = testconfig.repl_slot
|
||||||
self._slots = []
|
self._slots = []
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,9 @@ class ConnectingTestCase(unittest.TestCase):
|
||||||
Should raise a skip test if not available, but guard for None on
|
Should raise a skip test if not available, but guard for None on
|
||||||
old Python versions.
|
old Python versions.
|
||||||
"""
|
"""
|
||||||
|
if repl_dsn is None:
|
||||||
|
return self.skipTest("replication tests disabled by default")
|
||||||
|
|
||||||
if 'dsn' not in kwargs:
|
if 'dsn' not in kwargs:
|
||||||
kwargs['dsn'] = repl_dsn
|
kwargs['dsn'] = repl_dsn
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user