A few pytest plugins used by LogPass.
To use logpass_pytest_plugins install it with your package manager,
e.g. via pip:
pip install logpass_pytest_pluginsTo install plugin with all its dependencies use one of following extras:
auto_pytest_factoryboychannelsrest_framework
For instance, to install channels and rest_framework plugins with all
dependencies:
pip install logpass_pytest_plugins[channels,rest_framework]And finally add plugin import path to pytest_plugins in your root
conftest.py file, e.g. to use channels and rest_framework plugins:
# root `conftest.py`
pytest_plugins = (
'logpass_pytest_plugins.contrib.channels',
'logpass_pytest_plugins.contrib.rest_framework',
)NOTE: None plugin is not used by default - you need to enable them via pytest_plugins
Plugin that automatically registers factory_boy factories to
pytest-factoryboy, so factories and models instances will be available
as pytest fixtures.
Following INI options can be used to configure auto_pytest_factoryboy plugin:
auto_pytest_factoryboy_root_dir- directory where factories declarations searching starts (defaults to.- pytest config path)auto_pytest_factoryboy_globs- list ofglobpatterns used to find files withfactoryboyfactories declarations starting from theauto_pytest_factoryboy_root_dirdirectory (defaults to**/factories*.py)
Plugin that simplifies channels consumers testing by providing following
fixtures:
websocket_commmunicator_factory- factory ofWebSocketCommunicatorinstances, that will automatically disconnect at the end of a test. Using this fixture also automatically flush all used channel layershttp_commmunicator_factory- factory ofHttpCommunicatorinstances. Using this fixture also automatically flush all used channel layers
Plugin that simplifies flask views and other components testing
by providing following fixtures:
flask_app-Flaskapp instanceclient-FlaskClientinstance to use in tests
Following INI options can be used to configure flask plugin:
FLASK_SETTINGS_MODULE- import path to settings module when using flask's config from object. OverridesFLASK_SETTINGS_MODULEenvironment variable.FLASK_APP- import path to flask app factory or flask app instance. OverridesFLASK_APPenvironment variable.
To use flask plugin you need to do one of following:
- set
FLASK_APPINI option - set
FLASK_APPenvironment variable - define
flask_appfunction-scoped fixture in rootconftest.py
Plugin that simplifies rest_framework views and other components testing
by providing following fixtures:
api_rf-APIRequestFactoryinstanceapi_client-APIClientinstance