8000 Don't fail tests if the dummy table is already present. · wulczer/txpostgres@2efe142 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2efe142

Browse files
committed
Don't fail tests if the dummy table is already present.
On Postgres versions that support it, DROP TABLE IF EXISTS is used to clean up the dummy table before running the tests.
1 parent 8c14bf4 commit 2efe142

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/test_txpostgres.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class _SimpleDBSetupMixin(object):
449449
def setUp(self):
450450
d = self.restoreConnection(None)
451451
d.addCallback(lambda _: self.conn.cursor())
452-
return d.addCallback(lambda c: c.execute(simple_table_schema))
452+
return d.addCallback(self.createInitialSchema)
453453

454454
def tearDown(self):
455455
c = self.conn.cursor()
@@ -467,6 +467,12 @@ def restoreConnection(self, res):
467467
host=DB_HOST, database=DB_NAME)
468468
return d.addCallback(lambda _: res)
469469

470+
def createInitialSchema(self, c):
471+
d = defer.succeed(None)
472+
if self.conn.server_version > 80200:
473+
d.addCallback(lambda _: c.execute("drop table if exists simple"))
474+
return d.addCallback(lambda _: c.execute(simple_table_schema))
475+
470476

471477
class TxPostgresManualQueryTestCase(_SimpleDBSetupMixin, Psycopg2TestCase):
472478

0 commit comments

Comments
 (0)
0