← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:tachandler-debug-sql-extra into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:tachandler-debug-sql-extra into launchpad:master.

Commit message:
TacTestFixture: Ensure that LP_DEBUG_SQL_EXTRA=1 is not set

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/403956

This is similar to https://code.launchpad.net/~cjwatson/launchpad/tachandler-debug-sql/+merge/217228.  Apparently I missed a case at the time.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:tachandler-debug-sql-extra into launchpad:master.
diff --git a/lib/lp/services/daemons/tachandler.py b/lib/lp/services/daemons/tachandler.py
index 46ee2b5..4175b69 100644
--- a/lib/lp/services/daemons/tachandler.py
+++ b/lib/lp/services/daemons/tachandler.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test harness for TAC (Twisted Application Configuration) files."""
@@ -45,7 +45,7 @@ class TacTestSetup(TacTestFixture):
         # hard-to-diagnose race conditions. Delete the logfile to make sure
         # this does not happen.
         self.removeLog()
-        with override_environ(LP_DEBUG_SQL=None):
+        with override_environ(LP_DEBUG_SQL=None, LP_DEBUG_SQL_EXTRA=None):
             TacTestFixture.setUp(self,
                 python_path=sys.executable,
                 twistd_script=twistd_script)
diff --git a/lib/lp/services/daemons/tests/test_tachandler.py b/lib/lp/services/daemons/tests/test_tachandler.py
index 0b01898..5e275f6 100644
--- a/lib/lp/services/daemons/tests/test_tachandler.py
+++ b/lib/lp/services/daemons/tests/test_tachandler.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for lp.services.daemons.tachandler"""
@@ -105,6 +105,21 @@ class TacTestSetupTestCase(testtools.TestCase):
         # No warnings are emitted.
         self.assertEqual([], warnings_log)
 
+    def test_debug_sql_extra(self):
+        """TacTestSetup works even under LP_DEBUG_SQL_EXTRA=1."""
+        tempdir = self.useFixture(TempDir()).path
+        fixture = SimpleTac("okay", tempdir)
+
+        # Fire up the fixture, capturing warnings.
+        with override_environ(LP_DEBUG_SQL_EXTRA="1"):
+            with warnings.catch_warnings(record=True) as warnings_log:
+                with fixture:
+                    self.assertThat(fixture, IsRunning())
+                self.assertThat(fixture, Not(IsRunning()))
+
+        # No warnings are emitted.
+        self.assertEqual([], warnings_log)
+
     def test_missingTac(self):
         """TacTestSetup raises TacException if the tacfile doesn't exist"""
         fixture = SimpleTac("missing", "/file/does/not/exist")