Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb309f5

Browse files
author
vshepard
committed
Fix get_pg_version for linux mint
issue#100
1 parent5218b11 commitbb309f5

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

‎testgres/utils.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,23 @@ 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')ifbin_direlseget_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
186-
raw_ver=raw_ver.replace('(Homebrew)','').strip()
185+
returnparse_pg_version(raw_ver)
187186

188-
# cook version of PostgreSQL
189-
version=raw_ver.strip().split(' ')[-1] \
187+
188+
defparse_pg_version(version_out):
189+
# Generalize removal of system-specific suffixes (anything in parentheses)
190+
raw_ver=re.sub(r'\([^)]*\)','',version_out).strip()
191+
192+
# Cook version of PostgreSQL
193+
version=raw_ver.split(' ')[-1] \
190194
.partition('devel')[0] \
191195
.partition('beta')[0] \
192196
.partition('rc')[0]
193-
194197
returnversion
195198

196199

‎tests/test_simple.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
# NOTE: those are ugly imports
5050
fromtestgresimportbound_ports
51-
fromtestgres.utilsimportPgVer
51+
fromtestgres.utilsimportPgVer,parse_pg_version
5252
fromtestgres.nodeimportProcessProxy
5353

5454

@@ -1023,6 +1023,16 @@ def test_upgrade_node(self):
10231023
node_new.start()
10241024
self.assertTrue(b'Upgrade Complete'inres)
10251025

1026+
deftest_parse_pg_version(self):
1027+
# Linux Mint
1028+
assertparse_pg_version("postgres (PostgreSQL) 15.5 (Ubuntu 15.5-1.pgdg22.04+1)")=="15.5"
1029+
# Linux Ubuntu
1030+
assertparse_pg_version("postgres (PostgreSQL) 12.17")=="12.17"
1031+
# Windows
1032+
assertparse_pg_version("postgres (PostgreSQL) 11.4")=="11.4"
1033+
# Macos
1034+
assertparse_pg_version("postgres (PostgreSQL) 14.9 (Homebrew)")=="14.9"
1035+
10261036

10271037
if__name__=='__main__':
10281038
ifos.environ.get('ALT_CONFIG'):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp