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

Commitdc4b4c3

Browse files
author
vshepard
committed
Move _get_ssl_options in separate function
1 parente729c2f commitdc4b4c3

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

‎testgres/operations/os_ops.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,27 @@ def get_pid(self):
124124
defget_process_children(self,pid):
125125
raiseNotImplementedError()
126126

127+
def_get_ssl_options(self):
128+
"""
129+
Determine the SSL options based on available modules.
130+
"""
131+
ifself.conn_params.skip_ssl:
132+
if'psycopg2'insys.modules:
133+
return {"sslmode":"disable"}
134+
elif'pg8000'insys.modules:
135+
return {"ssl_context":None}
136+
return {}
137+
127138
# Database control
128139
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
129-
ssl_options={"sslmode":"disable"}ifself.conn_params.skip_ssland'psycopg2'insys.moduleselse {}
140+
ssl_options=self._get_ssl_options()
130141
conn=pglib.connect(
131142
host=host,
132143
port=port,
133144
database=dbname,
134145
user=user,
135146
password=password,
136-
**({"ssl_context":None}ifself.conn_params.skip_ssland'pg8000'insys.moduleselsessl_options)
147+
**ssl_options
137148
)
138149

139150
returnconn

‎tests/test_simple.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,9 +1039,11 @@ def test_parse_pg_version(self):
10391039
deftest_the_same_port(self):
10401040
withget_new_node()asnode:
10411041
node.init().start()
1042-
withget_new_node()asnode2:
1043-
node2.port=node.port
1044-
node2.init().start()
1042+
withget_new_node()asnode2:
1043+
node2.port=node.port
1044+
# _should_free_port is true if port was set up manually
1045+
node2._should_free_port=False
1046+
node2.init().start()
10451047

10461048
deftest_make_simple_with_bin_dir(self):
10471049
withget_new_node()asnode:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp