Skip to content

Commit ea11496

Browse files
testgres.utils.get_pg_version2 is added
This a version of get_pg_version that requires and uses an explicit os_ops object.
1 parent c07f112 commit ea11496

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

testgres/utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,29 @@ def cache_pg_config_data(cmd):
203203
return cache_pg_config_data("pg_config")
204204

205205

206-
def get_pg_version(bin_dir=None):
206+
def get_pg_version2(os_ops: OsOperations, bin_dir=None):
207207
"""
208208
Return PostgreSQL version provided by postmaster.
209209
"""
210+
assert os_ops is not None
211+
assert isinstance(os_ops, OsOperations)
210212

211213
# Get raw version (e.g., postgres (PostgreSQL) 9.5.7)
212-
postgres_path = os.path.join(bin_dir, 'postgres') if bin_dir else get_bin_path('postgres')
214+
postgres_path = os.path.join(bin_dir, 'postgres') if bin_dir else get_bin_path2(os_ops, 'postgres')
213215
_params = [postgres_path, '--version']
214-
raw_ver = tconf.os_ops.exec_command(_params, encoding='utf-8')
216+
raw_ver = os_ops.exec_command(_params, encoding='utf-8')
215217

216218
return parse_pg_version(raw_ver)
217219

218220

221+
def get_pg_version(bin_dir=None):
222+
"""
223+
Return PostgreSQL version provided by postmaster.
224+
"""
225+
226+
return get_pg_version2(tconf.os_ops, bin_dir)
227+
228+
219229
def parse_pg_version(version_out):
220230
# Generalize removal of system-specific suffixes (anything in parentheses)
221231
raw_ver = re.sub(r'\([^)]*\)', '', version_out).strip()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy