2828from port_for import PortForException , get_port
2929from pytest import FixtureRequest , TempPathFactory
3030
31- from pytest_postgresql .config import PostgresqlConfigDict , get_config
31+ from pytest_postgresql .config import PostgreSQLConfig , get_config
3232from pytest_postgresql .exceptions import ExecutableMissingException
3333from pytest_postgresql .executor import PostgreSQLExecutor
3434from pytest_postgresql .janitor import DatabaseJanitor
3535
3636PortType = port_for .PortType # mypy requires explicit export
3737
3838
39- def _pg_exe (executable : str | None , config : PostgresqlConfigDict ) -> str :
39+ def _pg_exe (executable : str | None , config : PostgreSQLConfig ) -> str :
4040 """If executable is set, use it. Otherwise best effort to find the executable."""
41- postgresql_ctl = executable or config [ " exec" ]
41+ postgresql_ctl = executable or config . exec
4242 # check if that executable exists, as it's no on systems' PATH
4343 # only replace it if executable isn't passed manually
4444 if not os .path .exists (postgresql_ctl ) and executable is None :
@@ -50,9 +50,9 @@ def _pg_exe(executable: str | None, config: PostgresqlConfigDict) -> str:
5050 return postgresql_ctl
5151
5252
53- def _pg_port (port : PortType | None , config : PostgresqlConfigDict , excluded_ports : Iterable [int ]) -> int :
53+ def _pg_port (port : PortType | None , config : PostgreSQLConfig , excluded_ports : Iterable [int ]) -> int :
5454 """User specified port, otherwise find an unused port from config."""
55- pg_port = get_port (port , excluded_ports ) or get_port (config [ " port" ] , excluded_ports )
55+ pg_port = get_port (port , excluded_ports ) or get_port (config . port , excluded_ports )
5656 assert pg_port is not None
5757 return pg_port
5858
@@ -115,8 +115,8 @@ def postgresql_proc_fixture(
115115 :returns: tcp executor
116116 """
117117 config = get_config (request )
118- pg_dbname = dbname or config [ " dbname" ]
119- pg_load = load or config [ " load" ]
118+ pg_dbname = dbname or config . dbname
119+ pg_load = load or config . load
120120 postgresql_ctl = _pg_exe (executable , config )
121121 port_path = tmp_path_factory .getbasetemp ()
122122 if hasattr (request .config , "workerinput" ):
@@ -138,7 +138,7 @@ def postgresql_proc_fixture(
138138 port_file .write (f"pg_port { pg_port } \n " )
139139 break
140140 except FileExistsError :
141- if n >= config [ " port_search_count" ] :
141+ if n >= config . port_search_count :
142142 raise PortForException (
143143 f"Attempted { n } times to select ports. "
144144 f"All attempted ports: { ', ' .join (map (str , used_ports ))} are already "
@@ -151,17 +151,17 @@ def postgresql_proc_fixture(
151151
152152 postgresql_executor = PostgreSQLExecutor (
153153 executable = postgresql_ctl ,
154- host = host or config [ " host" ] ,
154+ host = host or config . host ,
155155 port = pg_port ,
156- user = user or config [ " user" ] ,
157- password = password or config [ " password" ] ,
156+ user = user or config . user ,
157+ password = password or config . password ,
158158 dbname = pg_dbname ,
159- options = options or config [ " options" ] ,
159+ options = options or config . options ,
160160 datadir = str (datadir ),
161- unixsocketdir = unixsocketdir or config [ " unixsocketdir" ] ,
161+ unixsocketdir = unixsocketdir or config . unixsocketdir ,
162162 logfile = str (logfile_path ),
163- startparams = startparams or config [ " startparams" ] ,
164- postgres_options = postgres_options or config [ " postgres_options" ] ,
163+ startparams = startparams or config . startparams ,
164+ postgres_options = postgres_options or config . postgres_options ,
165165 )
166166 # start server
167167 with postgresql_executor :
@@ -174,7 +174,7 @@ def postgresql_proc_fixture(
174174 version = postgresql_executor .version ,
175175 password = postgresql_executor .password ,
176176 )
177- if config [ " drop_test_database" ] :
177+ if config . drop_test_database :
178178 janitor .drop ()
179179 with janitor :
180180 for load_element in pg_load :
0 commit comments