Added function to drop a test table in the doctest.

This commit is contained in:
Daniele Varrazzo 2010-02-14 11:57:20 +00:00
parent a54336f7b4
commit f134bceb00

View File

@ -241,13 +241,17 @@ def test_connect():
conn = test_connect() conn = test_connect()
cur = conn.cursor() cur = conn.cursor()
def create_test_table(): def drop_test_table(name):
cur.execute("SAVEPOINT drop_test_table;")
try: try:
cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)") cur.execute("DROP TABLE %s;" % name)
except: except:
conn.rollback() cur.execute("ROLLBACK TO SAVEPOINT drop_test_table;")
cur.execute("DELETE FROM test") conn.commit()
cur.execute("SELECT setval('test_id_seq', 1, False)")
def create_test_table():
drop_test_table('test')
cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)")
conn.commit() conn.commit()
""" """