Comments (3)
you'd want to do something more like
from pytest_mock_resources import create_postgres_fixture
pg = create_postgres_fixture(async_=True)
Under the hood, this fixture is depending on pmr_postgres_container
fixture and doing other fancy things (like waiting for the container to be ready), which is what is causing the container to spin up. Without that here, your fixture is just depending on the config fixture and not invoking any of the plugin internals.
Once you have this fixture, you can depend on it on with other fixtures; for example, if you wanted to retain your autouse
usage.
@pytest.fixture(scope='session', autouse=True)
async def async_engine(pg):
pass
With that said, I'd consider most scenarios that force you into redefining the fixture for this kind of purpose to be a defect of the library (i.e. we should add an autouse
flag, if so)
from pytest-mock-resources.
Thank you for fast response. Its getting better, i can now use pg fixture to run container and make connections. I now want to obtain the actual database name for tests (i dont want to hardcode pytest_mock_resource_db_*
) so i can instantiate separate engine and use it in my tests flow.
Can you share any suggestions on how this can be done correctly? Or is it possible at all from pg
fixture.
Thank you.
from pytest-mock-resources.
Got it, pg.engine.url.database
from pytest-mock-resources.
Related Issues (20)
- $round operation for MongoDB HOT 2
- SQLAlchemy 2.0 Support HOT 7
- Certain schema DDL is issued only once per test but should be once per metadata
- Dependabot warning for docker subdependency HOT 3
- [Support] Tests hang when using fixture HOT 7
- Error opening connection from redshift_connector HOT 5
- Add in Left/Right UDF's for Redshift HOT 2
- No such event 'before_execute' for target '<sqlalchemy.orm.session.Session object ... HOT 4
- Support SQLAlchemy 1.4 future mode HOT 4
- Dependency on attrs package should be explicit HOT 3
- get_sqlalchemy_engine() not compatible with asyncpg HOT 5
- Allow defining run_args HOT 1
- Getting errors when using `create_redis_fixture` HOT 3
- Missing delete function in redis fixture HOT 1
- Redis Container dont start after update Docker for Desktop on windows. HOT 6
- `create_postgres_fixture` doesn't clean up after running tests. HOT 6
- Allow using `psycopg` instead of `psycopg2` HOT 6
- create_postgres_fixture fails on 2.11.0 HOT 2
- psycopg2-binary is not considered as a suitable driver for Postgres. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-mock-resources.