Skip to content

Commit a1fdeb1

Browse files
author
vshepard
committed
Fix get_pg_version for linux mint
issue #100
1 parent 5218b11 commit a1fdeb1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

testgres/utils.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ def get_pg_version(bin_dir=None):
177177
Return PostgreSQL version provided by postmaster.
178178
"""
179179

180-
# get raw version (e.g. postgres (PostgreSQL) 9.5.7)
180+
# Get raw version (e.g. postgres (PostgreSQL) 9.5.7)
181181
postgres_path = os.path.join(bin_dir, 'postgres') if bin_dir else get_bin_path('postgres')
182182
_params = [postgres_path, '--version']
183183
raw_ver = tconf.os_ops.exec_command(_params, encoding='utf-8')
184184

185-
# Remove "(Homebrew)" if present
185+
# Remove "(Homebrew)" and "(Ubuntu <version>)" if present
186186
raw_ver = raw_ver.replace('(Homebrew)', '').strip()
187+
raw_ver = re.sub(r'\(Ubuntu[^)]*\)', '', raw_ver).strip()
187188

188-
# cook version of PostgreSQL
189-
version = raw_ver.strip().split(' ')[-1] \
189+
# Cook version of PostgreSQL
190+
version = raw_ver.split(' ')[-1] \
190191
.partition('devel')[0] \
191192
.partition('beta')[0] \
192193
.partition('rc')[0]

0 commit comments

Comments
 (0)