A Python module that attempts to fake out the uwsgi module exposed to uWSGI application. When testing applications outside uWSGI, for example Flask, this module can provide some functionality of the uwsgi module.
Project description
A Python module that attempts to fake out the uwsgi module exposed to uWSGI application. When testing applications outside uWSGI, for example Flask, this module can provide some functionality of the uwsgi module
fake_uwsgi attempts to replicate APIs and variables that the uwsgi module exposes to Python applications running in uWSGI.
GitHub repo: https://github.com/digimach/fake-uwsgi
Documentation: https://github.com/digimach/fake-uwsgi/blob/master/README.rst
Features
- Provides the following uwsgi module APIs:
log
set_logvar
get_logvar
worker_id
workers
total_requests
- Provides the following uwsgi module global variables:
numproc
opt
- Sets the following environment variables:
INSTALL_PATH
APP_RUN_MODE
Quickstart
In order to make use of Fake uWSGI everywhere import uwsgi is used has to be replaced with:
try: # The following import will fail if not running in uWSGI import uwsgi # pylint: disable=import-error except ImportError: import fake_uwsgi as uwsgi # pylint: disable-msg=ungrouped-imports
If your code makes use of other APIs and/or global variables that Fake uWSGI does not expose you have two options:
Monkey patch or expand the fake_uwsgi module inside your code.
Raise an feature request with this project.
Development
This project uses tox to setup a development environment. Make sure you have tox installed:
pip install tox
Clone this repository
You can setup the development environment by running the setup-dev make rule from the project directory:
make setup-dev
You can run tests by doing:
make test
To lint your code:
make lint
To format your code with Black run:
make black
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.