Merge lp:~frankban/launchpad/bug-985338-programming-error into lp:launchpad

Proposed by Francesco Banconi
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 15132
Proposed branch: lp:~frankban/launchpad/bug-985338-programming-error
Merge into: lp:launchpad
Diff against target: 12 lines (+5/-0)
1 file modified
lib/lp/testing/tests/test_pgsql.py (+5/-0)
To merge this branch: bzr merge lp:~frankban/launchpad/bug-985338-programming-error
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+102815@code.launchpad.net

Description of the change

= Summary =

lp.testing.tests.test_pgsql.TestPgTestSetupTuning.testOptimization
intermittently raises a ProgrammingError. This happens when the test is run
after test_sequences (in the same TestCase). The latter doesn't destroy the
database used for tests, and so the former generates an error attempting
to create an existing table.

== Proposed fix ==

Drop the database in test_sequences.

== Implementation details ==

See proposed fix.

== Tests ==

$ bin/test -vv -t lp.testing.tests.test_pgsql.TestPgTestSetupTuning
Running tests at level 1
Running lp.testing.layers.BaseLayer tests:
  Set up lp.testing.layers.BaseLayer in 0.070 seconds.
  Running:
 testOptimization (lp.testing.tests.test_pgsql.TestPgTestSetupTuning)
 test_sequences (lp.testing.tests.test_pgsql.TestPgTestSetupTuning)
  Ran 2 tests with 0 failures and 0 errors in 1.474 seconds.
Tearing down left over layers:
  Tear down lp.testing.layers.BaseLayer in 0.001 seconds.

$ bin/test -vv --shuffle -t lp.testing.tests.test_pgsql.TestPgTestSetupTuning
Running tests at level 1
Running lp.testing.layers.BaseLayer tests:
  Set up lp.testing.layers.BaseLayer in 0.070 seconds.
  Running:
 test_sequences (lp.testing.tests.test_pgsql.TestPgTestSetupTuning)
 testOptimization (lp.testing.tests.test_pgsql.TestPgTestSetupTuning)
  Ran 2 tests with 0 failures and 0 errors in 1.484 seconds.
Tearing down left over layers:
  Tear down lp.testing.layers.BaseLayer in 0.001 seconds.
Tests were shuffled using seed number 341718873136.

== Demo and Q/A ==

no-qa

== lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/testing/tests/test_pgsql.py

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/testing/tests/test_pgsql.py'
2--- lib/lp/testing/tests/test_pgsql.py 2011-12-29 05:29:36 +0000
3+++ lib/lp/testing/tests/test_pgsql.py 2012-04-20 09:24:19 +0000
4@@ -193,3 +193,8 @@
5 # Fail if we got a diffent sequence value at some point
6 for v in sequence_values:
7 self.failUnlessEqual(v, sequence_values[0])
8+
9+ # The database still exists because, after the last commit,
10+ # ConnectionWrapper.committed was set to False.
11+ # Drop the database here to avoid test ordering issues.
12+ fixture.dropDb()