Closed Popkornium18 closed 5 months ago
I believe the psycopg
driver should work, if you configure it: https://pytest-mock-resources.readthedocs.io/en/latest/postgres.html
With that said, our code is already doing some automatic swapping of the default driver based on heuristics. I suppose we could introspect whether one or the other driver is installed and make a more intelligent dynamic selection when it's unset.
How would I configure create_postgres_fixture()
to use the modified PostgresConfig
? Just including the pmr_postgres_config
fixture results in a fixture scope mismatch.
Edit: I see, modifying the scope seems to be the way to go.
The example in https://pytest-mock-resources.readthedocs.io/en/latest/postgres.html is missing a return
.
i shall fix the docs alongside the improved default heuristics, should probably look like:
from pytest_mock_resources import PostgresConfig
@pytest.fixture(scope='session')
def pmr_postgres_config():
return PostgresConfig(drivername='postgresql+psycopg2') # but whatever driver you require.
If you're interested in it doing the "right" thing by default, feel free to try out the above branch before I merge it.
I'll do that tomorrow.
Right now testing non-async with postgres requires the use of the legacy
psycopg2
package.psycopg
is the successor topsycopg2
with a very unfortunate name. It is recommended to use the newer package unless you are maintaining an existing application which can't be migrated. It would be great if PMR would allow (and maybe default to) the use of the more modernpsycopg
package.