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

Can't execute multiple tests in parallel #54

Closed DanCardin closed 5 years ago

DanCardin commented 5 years ago

Is your feature request related to a problem? Please describe. pytest -n 4

E       sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "pg_database_datname_index"
E       DETAIL:  Key (datname)=(pytest_mock_resource_db_386) already exists.
E        [SQL: 'CREATE DATABASE "pytest_mock_resource_db_386"'] (Background on this error at: http://sqlalche.me/e/gkpj)

Describe the solution you'd like Starting here: https://github.com/schireson/schireson-pytest-mock-resources/blob/master/src/pytest_mock_resources/fixture/database/relational/postgresql.py#L110

we shouldn't be setting the isolation level like that, firstly. but lastly the way that it's allocating the database names means we can't execute tests in parallel.

This is really unfortunate because otherwise the design seems really amenable to parallel use. This is a hard blocker to use in apis like flight-manager which would be really nice!