schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

Redshift patches are applied to all psycop2 database connections in that test #83

Closed DanCardin closed 2 years ago

DanCardin commented 4 years ago

Describe the bug The redshift patch of psycopg2 connect and/or sqlalchemy create_engine is unconditional, and therefore will modify a call to those functions for engines which are not the one we're trying to connect to.

I.e. if you create 2 fixtures, a postgres one and a redshift one and attempt to use them both in the same test.

Possible solution: Conditionally apply the patch based on the DSN of the call. Ideally on as many fields as we can to stay frugal on the patch. like certainly drivername/host/port and maybe database