Merge lp:~allenap/postgresfixture/trusty-compatibility into lp:~lazr-developers/postgresfixture/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: 9
Merged at revision: 9
Proposed branch: lp:~allenap/postgresfixture/trusty-compatibility
Merge into: lp:~lazr-developers/postgresfixture/trunk
Diff against target: 51 lines (+19/-4)
2 files modified
postgresfixture/cluster.py (+12/-3)
postgresfixture/tests/test_cluster.py (+7/-1)
To merge this branch: bzr merge lp:~allenap/postgresfixture/trusty-compatibility
Reviewer Review Type Date Requested Status
Gavin Panella Approve
Review via email: mp+202151@code.launchpad.net

Commit message

Accommodate differences between PostgreSQL's pg_ctl in version 9.1 and >= 9.2.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Selfie.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'postgresfixture/cluster.py'
--- postgresfixture/cluster.py 2014-01-17 16:35:21 +0000
+++ postgresfixture/cluster.py 2014-01-17 17:57:51 +0000
@@ -141,10 +141,19 @@
141 try:141 try:
142 self.execute("pg_ctl", "status", stdout=null)142 self.execute("pg_ctl", "status", stdout=null)
143 except CalledProcessError as error:143 except CalledProcessError as error:
144 if error.returncode == 1:144 # pg_ctl in PostgreSQL 9.1 returns 1 when the server is
145 return False145 # not running, whereas it returns 3 in PostgreSQL 9.2
146 # and later. This checks for specific codes to avoid
147 # masking errors from insufficient permissions or
148 # missing executables, for example.
149 if LooseVersion(self.version) >= LooseVersion("9.2"):
150 if error.returncode == 3:
151 return False
146 else:152 else:
147 raise153 if error.returncode == 1:
154 return False
155 # Some other error: moan about it.
156 raise
148 else:157 else:
149 return True158 return True
150159
151160
=== modified file 'postgresfixture/tests/test_cluster.py'
--- postgresfixture/tests/test_cluster.py 2014-01-17 16:35:21 +0000
+++ postgresfixture/tests/test_cluster.py 2014-01-17 17:57:51 +0000
@@ -13,6 +13,7 @@
13__all__ = []13__all__ = []
1414
15from contextlib import closing15from contextlib import closing
16from distutils.version import LooseVersion
16from os import (17from os import (
17 getpid,18 getpid,
18 path,19 path,
@@ -177,7 +178,12 @@
177 self.assertEqual(("pg_ctl", "status"), command)178 self.assertEqual(("pg_ctl", "status"), command)
178179
179 def test_running_not(self):180 def test_running_not(self):
180 self.patch_check_call(returncode=1)181 # pg_ctl in PostgreSQL 9.1 returns 1 when the server is not
182 # running, whereas it returns 3 in PostgreSQL 9.2 and later.
183 if LooseVersion(self.version) >= LooseVersion("9.2"):
184 self.patch_check_call(returncode=3)
185 else:
186 self.patch_check_call(returncode=1)
181 cluster = self.make(self.make_dir())187 cluster = self.make(self.make_dir())
182 self.assertFalse(cluster.running)188 self.assertFalse(cluster.running)
183189

Subscribers

People subscribed via source and target branches

to all changes: