Added a couple of test scripts to sandbox

This commit is contained in:
Federico Di Gregorio 2009-04-19 16:25:49 +02:00
parent bb77a6912f
commit e3a5ae8e20
4 changed files with 84 additions and 2 deletions

View File

@ -0,0 +1,70 @@
# =======================================================================
# $Source: /sources/gnumed/gnumed/gnumed/client/testing/test-psycopg2-datetime-systematic.py,v $
__version__ = "$Revision: 1.1 $"
__author__ = "K.Hilbert <Karsten.Hilbert@gmx.net>"
__license__ = 'GPL (details at http://www.gnu.org)'
# =======================================================================
print "testing psycopg2 date/time parsing"
import psycopg2
print "psycopg2:", psycopg2.__version__
#dsn = u'dbname=gnumed_v10 user=any-doc password=any-doc'
dsn = u'dbname=test'
print dsn
conn = psycopg2.connect(dsn=dsn)
curs = conn.cursor()
cmd = u"""
select
name,
abbrev,
utc_offset::text,
case when
is_dst then 'DST'
else 'non-DST'
end
from pg_timezone_names"""
curs.execute(cmd)
rows = curs.fetchall()
curs.close()
conn.rollback()
for row in rows:
curs = conn.cursor()
tz = row[0]
cmd = u"set timezone to '%s'" % tz
try:
curs.execute(cmd)
except StandardError, e:
print "cannot use time zone", row
raise e
curs.close()
conn.rollback()
continue
cmd = u"""select '1920-01-19 23:00:00+01'::timestamp with time zone"""
try:
curs.execute(cmd)
curs.fetchone()
except StandardError, e:
print "%s (%s / %s / %s) failed:" % (tz, row[1], row[2], row[3])
print " ", e
curs.close()
conn.rollback()
conn.close()
# =======================================================================
# $Log: test-psycopg2-datetime-systematic.py,v $
# Revision 1.1 2009/02/10 18:45:32 ncq
# - psycopg2 cannot parse a bunch of settable time zones
#
# Revision 1.1 2009/02/10 13:57:03 ncq
# - test for psycopg2 on Ubuntu-Intrepid
#

12
sandbox/test_notices.py Normal file
View File

@ -0,0 +1,12 @@
def test():
import sys, os, thread, psycopg2
def test2():
while True:
for filename in map(lambda m: getattr(m, "__file__", None), sys.modules.values()):
os.stat("/dev/null")
connection = psycopg2.connect(database="test")
cursor = connection.cursor()
thread.start_new_thread(test2, ())
while True:
cursor.execute("COMMIT")
test()

View File

@ -1,5 +1,5 @@
[build_ext]
define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3
define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3,PSYCOPG_DEBUG
# PSYCOPG_EXTENSIONS enables extensions to PEP-249 (you really want this)
# PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)

View File

@ -216,7 +216,7 @@ class psycopg_build_ext(build_ext):
define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" %
(int(pgmajor), int(pgminor), int(pgpatch))))
except Warning, w:
except (Warning, w):
if self.pg_config == self.DEFAULT_PG_CONFIG:
sys.stderr.write("Warning: %s" % str(w))
else: