You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am continuing to write a plugin for pytest that implements an alternative to assert adding some extra options (warning and error conditions, continue on failure etc.) and saving all results.
I save the results of my "alternative assert" function and track the current module, class, test function, fixture (inc scope) and test stage (to differntiate between results of setup, call and teardown) for each invocation of the function.
I currently do this by saving these as class attributes so they can be used by the plugin modules during a single test session. pytest_runtest_setup - start/end of setup stage for a specific test function pytest_fixture_setup - setup section of a specific fixture starting/completed - scope of fixture is known so all results for the fixture can be associated with all relavent tests pytest_fixture_post_finalizer - specific fixture teardown complete pytest_pyfunc_call - call stage started for specified function pytest_runtest_teardown - start/end of teardown stage for a specific test
The other possible implementation of this would be to add them to the pytest namespace but it is not recommended and deprecated!
All the information is inserted into a database as it is retrieved from the pytest hooks, so another possible solution is to retrieve the information from the database rather than keeping track of globals. This is not ideal however becuase I'd like to keep an option to run tests without logging to the database.
Is there a better way to do this?
Any pytest functions I am missing that I can call from my plugin to retrieve the current test, stage fixture, scope?
pytest: 3.6.3
python: 3.5.2
An example output of the plugin results for a test module containing 4 tests is shown below:
Note that test_1_module_scope and test_2_module_scope are module test functions test_3_class_scope and test_4_class_scope are test methods of the TestClass class
The text was updated successfully, but these errors were encountered:
GitMate.io thinks possibly related issues are #538 (Fixture scope documentation), #768 (doctests appear to run before session scope fixtures), #2732 (Fixture scope mixing?), #948 (session scope fixtures can't run tests which does not start with test* or setup*), and #660 (Module scope fixture runs on function scope).
I am continuing to write a plugin for pytest that implements an alternative to assert adding some extra options (warning and error conditions, continue on failure etc.) and saving all results.
I save the results of my "alternative assert" function and track the current module, class, test function, fixture (inc scope) and test stage (to differntiate between results of setup, call and teardown) for each invocation of the function.
I currently do this by saving these as class attributes so they can be used by the plugin modules during a single test session.
pytest_runtest_setup
- start/end of setup stage for a specific test functionpytest_fixture_setup
- setup section of a specific fixture starting/completed - scope of fixture is known so all results for the fixture can be associated with all relavent testspytest_fixture_post_finalizer
- specific fixture teardown completepytest_pyfunc_call
- call stage started for specified functionpytest_runtest_teardown
- start/end of teardown stage for a specific testThe other possible implementation of this would be to add them to the pytest namespace but it is not recommended and deprecated!
All the information is inserted into a database as it is retrieved from the pytest hooks, so another possible solution is to retrieve the information from the database rather than keeping track of globals. This is not ideal however becuase I'd like to keep an option to run tests without logging to the database.
Is there a better way to do this?
Any pytest functions I am missing that I can call from my plugin to retrieve the current test, stage fixture, scope?
pytest: 3.6.3
python: 3.5.2
An example output of the plugin results for a test module containing 4 tests is shown below:
Note that
test_1_module_scope
andtest_2_module_scope
are module test functionstest_3_class_scope
andtest_4_class_scope
are test methods of the TestClass classThe text was updated successfully, but these errors were encountered: