Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Unit-Tests depend on functional tests #91

Open
g-tom opened this issue Sep 7, 2017 · 3 comments
Open

Unit-Tests depend on functional tests #91

g-tom opened this issue Sep 7, 2017 · 3 comments

Comments

@g-tom
Copy link

g-tom commented Sep 7, 2017

While running all automatic tests with py.test --app-config test.ini -x as well as running only functional tests with py.test --app-config test.ini -x ringo/tests/functional/ works, running only unit tests with py.test --app-config test.ini -x ringo/tests/unit/ or a single unit test with e.g. py.test --app-config test.ini -x ringo/tests/unit/test_helpers.py fails with an UnboundExecutionError in get_bind().

@g-tom
Copy link
Author

g-tom commented Sep 7, 2017

A workaround to avoid having to run all the tests is to run any functional tests before running any unit test, e.g.:

py.test --app-config test.ini ringo/tests/functional/test_user.py ringo/tests/unit/test_helpers.py

@g-tom
Copy link
Author

g-tom commented Sep 7, 2017

or a single unit test with e.g. py.test --app-config test.ini -x ringo/tests/unit/test_helpers.py

This is not true for all unit tests but for BaseItemTests and test_get_item_actions in test_base_model.py, test_get_action_url_list and test_import_model in test_helpers.py, test_login_ok and test_login_fail in test_security.py. All of them seem to use DBSession:

DBSession = scoped_session(
sessionmaker(
query_cls=query.query_callable(regions),
)
)

e.g. through BaseFactory.load():

def load(self, id, db=None, cache="", uuid=False, field=None):

DBSession is configured from within main() in init.py, which is called in the app-fixture of pytest-ringo used in the functional tests. As a side effect, unit tests work after functional tests in the same run.

@g-tom
Copy link
Author

g-tom commented Sep 7, 2017

ringo-framework/pytest-ringo#1 makes it possible to run unit tests without functional tests. However, the side effect of functional tests remains. Probably their should be some tearDown to avoid this.

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

No branches or pull requests

1 participant