Pytest's plugins crafted by LogPass
Project description
LogPass pytest plugins
A few pytest plugins used by LogPass.
Installation
To use logpass_pytest_plugins
install it with your package manager,
e.g. via pip:
pip install logpass_pytest_plugins
To install plugin with all its dependencies use one of following extras:
auto_pytest_factoryboy
channels
rest_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',
)
Available plugins
NOTE: None plugin is not used by default - you need to enable them via pytest_plugins
logpass_pytest_plugins.contrib.auto_pytest_factoryboy
Plugin that automatically registers factory_boy
factories to
pytest-factoryboy
, so factories and models instances will be available
as pytest fixtures.
Configuration
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 ofglob
patterns used to find files withfactoryboy
factories declarations starting from theauto_pytest_factoryboy_root_dir
directory (defaults to**/factories*.py
)
logpass_pytest_plugins.contrib.channels
Plugin that simplifies channels
consumers testing by providing following
fixtures:
websocket_commmunicator_factory
- factory ofWebSocketCommunicator
instances, that will automatically disconnect at the end of a test. Using this fixture also automatically flush all used channel layershttp_commmunicator_factory
- factory ofHttpCommunicator
instances. Using this fixture also automatically flush all used channel layers
logpass_pytest_plugins.contrib.flask
Plugin that simplifies flask
views and other components testing
by providing following fixtures:
flask_app
-Flask
app instanceclient
-FlaskClient
instance 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_MODULE
environment variable.FLASK_APP
- import path to flask app factory or flask app instance. OverridesFLASK_APP
environment variable.
To use flask
plugin you need to do one of following:
- set
FLASK_APP
INI option - set
FLASK_APP
environment variable - define
flask_app
function-scoped fixture in rootconftest.py
logpass_pytest_plugins.contrib.rest_framework
Plugin that simplifies rest_framework
views and other components testing
by providing following fixtures:
api_rf
-APIRequestFactory
instanceapi_client
-APIClient
instance
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file logpass_pytest_plugins-0.1.0.tar.gz
.
File metadata
- Download URL: logpass_pytest_plugins-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.5 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34d2163739abb33131190168dadeb26bc4c8f0d2185e6fb6041a7a124b83fa78 |
|
MD5 | 6c5ffa52e61f649a366a03a9f5b95337 |
|
BLAKE2b-256 | c5abbc912f9d22934c1141bff9e8490474b7ebe724d0e4e044927e4c6902d908 |
File details
Details for the file logpass_pytest_plugins-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: logpass_pytest_plugins-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.5 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5b6a08ddcd7663a387f231bb1debd5657281b3629688ad5c6a50a4c125e4b6a |
|
MD5 | b4aa2c030ba45f5ee06020352268664c |
|
BLAKE2b-256 | 7403f7504f67c3f054a146069b37c52e8d8235e0e32bd9ae0cb80575d186efde |