launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01372
[Merge] lp:~lifeless/launchpad/test into lp:launchpad/devel
Robert Collins has proposed merging lp:~lifeless/launchpad/test into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Make memcache/database/librarian layers tolerant of being torn down twice to cater to zope.testrunner layer behaviour.
--
https://code.launchpad.net/~lifeless/launchpad/test/+merge/37571
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/test into lp:launchpad/devel.
=== modified file 'lib/canonical/testing/layers.py'
--- lib/canonical/testing/layers.py 2010-10-04 06:20:04 +0000
+++ lib/canonical/testing/layers.py 2010-10-05 08:38:46 +0000
@@ -482,9 +482,12 @@
# memcached.
_memcached_process = None
+ _setup = False
+
@classmethod
@profiled
def setUp(cls):
+ cls._setup = True
# Create a client
MemcachedLayer.client = memcache_client_factory()
if (BaseLayer.persist_test_services and
@@ -531,6 +534,9 @@
@classmethod
@profiled
def tearDown(cls):
+ if not cls._setup:
+ return
+ cls._setup = False
MemcachedLayer.client.disconnect_all()
MemcachedLayer.client = None
if not BaseLayer.persist_test_services:
@@ -568,9 +574,12 @@
"""
_reset_between_tests = True
+ _setup = False
+
@classmethod
@profiled
def setUp(cls):
+ cls._setup = True
if not LibrarianLayer._reset_between_tests:
raise LayerInvariantError(
"_reset_between_tests changed before LibrarianLayer "
@@ -584,6 +593,9 @@
@classmethod
@profiled
def tearDown(cls):
+ if not cls._setup:
+ return
+ cls._setup = False
if not LibrarianLayer._reset_between_tests:
raise LayerInvariantError(
"_reset_between_tests not reset before LibrarianLayer "
@@ -680,9 +692,12 @@
# Database.force_dirty_database() when you do so.
_reset_between_tests = True
+ _setup = False
+
@classmethod
@profiled
def setUp(cls):
+ cls._setup = True
DatabaseLayer.force_dirty_database()
# Imported here to avoid circular import issues. This
# functionality should be migrated into this module at some
@@ -695,6 +710,9 @@
@classmethod
@profiled
def tearDown(cls):
+ if not cls._setup:
+ return
+ cls._setup = False
# Don't leave the DB lying around or it might break tests
# that depend on it not being there on startup, such as found
# in test_layers.py