Closed mathiasose closed 4 years ago
Okay, this makes sense. It's possible to add this without too much trouble, if you'd like to open a pull request. (You can also wait for me to get around to it in like six years. 🙂)
To do so, you can modify pytest_addoption
here to add another argument, something like --pg-conf-opt
where you can specify a key-value pair like so:
pytest tests --pg-conf-opt="shared_preload_libraries='timescaledb'"
# or multiple ones
pytest tests --pg-conf-opt="key1='value1'" --pg-conf-opt="key2=value2"
You'd add a call that'd look something like this:
parser.addoption(
'--pg-conf-opt',
action='append',
help='useful text')
Then here you'd add another part to postgres_args
like:
conf_opts = request.config.getoption('--pg-conf-opt')
if conf_opts:
conf_opts_string = ' -c ' + ' -c '.join(conf_opts)
else:
conf_opts_string = ''
with testing.postgresql.Postgresql(
postgres_args=...
'-c bgwriter_delay=10000ms'
+ conf_opts_string) as pgdb:
yield pgdb.url()
I think this will work. Please feel free to open a pull request with these changes if you like.
This feature is available as of version 1.1.2
I'm trying to set up some tests for a service that uses the TimescaleDB extension.
pytest-pgsql
looks promising, but I can't find a way to set theshared_preloading_libraries
setting inpostgresql.conf
that TimescaleDB seems to require.Simple failing example:
The error message suggests
editing the config file at: /tmp/tmpc2d4u9wn/data/postgresql.conf
, but since that config file is ephemeral that doesn't help. It also suggestsSET timescaledb.allow_install_without_preload = 'on';
might help. I tried creating a fixture to run that expression before using the extension, but that just gave me a different error message (sqlalchemy.exc.InternalError: (psycopg2.InternalError) cannot create PGC_POSTMASTER variables after startup
).