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
Contents
- 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
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_uwsgimodule inside your code.- Raise an feature request with this project.
This project uses tox to setup a development environment. Make sure you have
toxinstalled:pip install tox
Clone this repository
You can setup the development environment by running the
setup-devmake 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