mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Added a couple of test scripts to sandbox
This commit is contained in:
parent
bb77a6912f
commit
e3a5ae8e20
70
sandbox/test-psycopg2-datetime-systematic.py
Normal file
70
sandbox/test-psycopg2-datetime-systematic.py
Normal 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
12
sandbox/test_notices.py
Normal 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()
|
|
@ -1,5 +1,5 @@
|
||||||
[build_ext]
|
[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_EXTENSIONS enables extensions to PEP-249 (you really want this)
|
||||||
# PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)
|
# PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -216,7 +216,7 @@ class psycopg_build_ext(build_ext):
|
||||||
|
|
||||||
define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" %
|
define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" %
|
||||||
(int(pgmajor), int(pgminor), int(pgpatch))))
|
(int(pgmajor), int(pgminor), int(pgpatch))))
|
||||||
except Warning, w:
|
except (Warning, w):
|
||||||
if self.pg_config == self.DEFAULT_PG_CONFIG:
|
if self.pg_config == self.DEFAULT_PG_CONFIG:
|
||||||
sys.stderr.write("Warning: %s" % str(w))
|
sys.stderr.write("Warning: %s" % str(w))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user