Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coarser Fixture Scopes #50

Closed
ghost opened this issue Feb 5, 2017 · 4 comments
Closed

Coarser Fixture Scopes #50

ghost opened this issue Feb 5, 2017 · 4 comments
Assignees

Comments

@ghost
Copy link

ghost commented Feb 5, 2017

My conftest.py, probably non-ideal, attempts to depend a session-scoped SQLAlchemy engine upon the pyramid_config fixture. Py.test disallows depending a session-scoped fixture on another function-scoped fixture. A knob to control pyramid_config granularity would be nice.

@ghost ghost changed the title Coarser Coarser Fixture Scopes Feb 5, 2017
@fizyk
Copy link
Owner

fizyk commented Feb 5, 2017

@bradmwalker I'd stronglu suggest rather changing the session-scoped SQLAlchemy engine to be rather function scoped.

Se conftest.py for my pyramid_fullath pyramid's plugin: https://github.com/fizyk/pyramid_fullauth/blob/master/tests/conftest.py#L39

Session living in between tests suggest that the data might live also affecting other tests. Clean slate for each test is always preferable.

@fizyk fizyk self-assigned this Feb 5, 2017
@ghost
Copy link
Author

ghost commented Feb 5, 2017

I use one session-scoped fixture for SA engine + sessionmaker initialization (and potentially schema initialization), and a dependent function-scoped fixture to yield individual sessions from the sessionmaker for clean state.

Session-scoping might be a sane default for the configuration fixture. Websauna sets session-scoping for its config and WSGI app fixtures: https://websauna.org/_modules/websauna/tests/conftest.html

@fizyk
Copy link
Owner

fizyk commented Feb 7, 2017

Well... you might be right, that the config is simple enough to be session scoped anyway. It's not like it's a database...

@fizyk fizyk closed this as completed in f82b71a Feb 7, 2017
fizyk added a commit that referenced this issue Feb 7, 2017
change pyramid_config fixture scope to session - closes #50.
@fizyk
Copy link
Owner

fizyk commented Feb 7, 2017

@bradmwalker version 0.3.0 should be in a minute uploaded to pypi. Thanks for pointing out that the config fixture could be rather session scoped.

Happy testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant