From f134bceb009dc5eaa18fc52cd36951ca1e696992 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 14 Feb 2010 11:57:20 +0000 Subject: [PATCH] Added function to drop a test table in the doctest. --- doc/conf.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 5f23a29f..1577bac1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -241,13 +241,17 @@ def test_connect(): conn = test_connect() cur = conn.cursor() -def create_test_table(): +def drop_test_table(name): + cur.execute("SAVEPOINT drop_test_table;") try: - cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)") + cur.execute("DROP TABLE %s;" % name) except: - conn.rollback() - cur.execute("DELETE FROM test") - cur.execute("SELECT setval('test_id_seq', 1, False)") + cur.execute("ROLLBACK TO SAVEPOINT drop_test_table;") + conn.commit() + +def create_test_table(): + drop_test_table('test') + cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)") conn.commit() """