File tree 6 files changed +11
-10
lines changed
6 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ def __init__(
69
69
logfile : str ,
70
70
startparams : str ,
71
71
dbname : str ,
72
+ template_dbname : str ,
72
73
shell : bool = False ,
73
74
timeout : Optional [int ] = 60 ,
74
75
sleep : float = 0.1 ,
@@ -102,6 +103,7 @@ def __init__(
102
103
self .user = user
103
104
self .password = password
104
105
self .dbname = dbname
106
+ self .template_dbname = template_dbname
105
107
self .options = options
106
108
self .datadir = datadir
107
109
self .unixsocketdir = unixsocketdir
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ def __init__(
37
37
user : str ,
38
38
options : str ,
39
39
dbname : str ,
40
+ template_dbname : str ,
40
41
password : Optional [str ] = None ,
41
42
):
42
43
"""Initialize nooperator executor mock.
@@ -54,6 +55,7 @@ def __init__(
54
55
self .options = options
55
56
self .password = password
56
57
self .dbname = dbname
58
+ self .template_dbname = template_dbname
57
59
self ._version : Any = None
58
60
59
61
@property
Original file line number Diff line number Diff line change @@ -63,11 +63,7 @@ def postgresql_factory(request: FixtureRequest) -> Iterator[Connection]:
63
63
pg_user = proc_fixture .user
64
64
pg_password = proc_fixture .password
65
65
pg_options = proc_fixture .options
66
- pg_db = dbname
67
- pg_template = None
68
- if not dbname :
69
- pg_db = proc_fixture .dbname
70
- pg_template = f"{ pg_db } _tmpl"
66
+ pg_db = dbname or proc_fixture .dbname
71
67
pg_load = load or []
72
68
if pg_load :
73
69
warnings .warn (
@@ -84,7 +80,7 @@ def postgresql_factory(request: FixtureRequest) -> Iterator[Connection]:
84
80
host = pg_host ,
85
81
port = pg_port ,
86
82
dbname = pg_db ,
87
- template_dbname = pg_template ,
83
+ template_dbname = proc_fixture . template_dbname ,
88
84
version = proc_fixture .version ,
89
85
password = pg_password ,
90
86
isolation_level = isolation_level ,
Original file line number Diff line number Diff line change @@ -79,14 +79,14 @@ def postgresql_noproc_fixture(request: FixtureRequest) -> Iterator[NoopExecutor]
79
79
user = pg_user ,
80
80
password = pg_password ,
81
81
dbname = pg_dbname ,
82
+ template_dbname = f"{ pg_dbname } _tmpl" ,
82
83
options = pg_options ,
83
84
)
84
- template_dbname = f"{ noop_exec .dbname } _tmpl"
85
85
with DatabaseJanitor (
86
86
user = noop_exec .user ,
87
87
host = noop_exec .host ,
88
88
port = noop_exec .port ,
89
- template_dbname = template_dbname ,
89
+ template_dbname = noop_exec . template_dbname ,
90
90
version = noop_exec .version ,
91
91
password = noop_exec .password ,
92
92
) as janitor :
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ def postgresql_proc_fixture(
126
126
user = user or config ["user" ],
127
127
password = password or config ["password" ],
128
128
dbname = pg_dbname ,
129
+ template_dbname = f"{ pg_dbname } _tmpl" ,
129
130
options = options or config ["options" ],
130
131
datadir = str (datadir ),
131
132
unixsocketdir = unixsocketdir or config ["unixsocketdir" ],
@@ -136,12 +137,11 @@ def postgresql_proc_fixture(
136
137
# start server
137
138
with postgresql_executor :
138
139
postgresql_executor .wait_for_postgres ()
139
- template_dbname = f"{ postgresql_executor .dbname } _tmpl"
140
140
with DatabaseJanitor (
141
141
user = postgresql_executor .user ,
142
142
host = postgresql_executor .host ,
143
143
port = postgresql_executor .port ,
144
- template_dbname = template_dbname ,
144
+ template_dbname = postgresql_executor . template_dbname ,
145
145
version = postgresql_executor .version ,
146
146
password = postgresql_executor .password ,
147
147
) as janitor :
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def __init__(
39
39
:param host: postgresql host
40
40
:param port: postgresql port
41
41
:param dbname: database name
42
+ :param dbname: template database name
42
43
:param version: postgresql version number
43
44
:param password: optional postgresql password
44
45
:param isolation_level: optional postgresql isolation level
You can’t perform that action at this time.
0 commit comments