launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25079
[Merge] ~cjwatson/launchpad:testfix-run-isolated-force-dirty-db into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:testfix-run-isolated-force-dirty-db into launchpad:master.
Commit message:
Force dirty database in RunIsolatedTest
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387966
If we've run a test in a subprocess, we don't have a good way to tell whether it committed any database transactions. Force the database layer to reset the database just in case, fixing a test isolation bug.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:testfix-run-isolated-force-dirty-db into launchpad:master.
diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py
index a4f4bac..a2c9448 100644
--- a/lib/lp/testing/__init__.py
+++ b/lib/lp/testing/__init__.py
@@ -1234,6 +1234,9 @@ class RunIsolatedTest(testtools.RunTest):
result.stopTest(self.case)
def _run_started(self, result):
+ # Circular import.
+ from lp.testing.layers import DatabaseLayer
+
pread, pwrite = os.pipe()
# We flush __stdout__ and __stderr__ at this point in order to avoid
# bug 986429; they get copied in full when we fork, which means that
@@ -1274,6 +1277,8 @@ class RunIsolatedTest(testtools.RunTest):
protocol.readFrom(fdread)
fdread.close()
os.waitpid(pid, 0)
+ if issubclass(self.case.layer, DatabaseLayer):
+ self.case.layer.force_dirty_database()
class EventRecorder: