Skip to content

digimach/fake-uwsgi

Repository files navigation

Fake uWSGI

Python Versions Test Status License Code Style https://deepsource.io/gh/digimach/fake-uwsgi.svg/?label=resolved+issues https://deepsource.io/gh/digimach/fake-uwsgi.svg/?label=active+issues https://scrutinizer-ci.com/g/digimach/fake-uwsgi/badges/quality-score.png?b=master CodeFactor https://codecov.io/gh/digimach/fake-uwsgi/branch/master/graph/badge.svg?token=HDF2UGHDPU

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.

  • 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:

  1. Monkey patch or expand the fake_uwsgi module inside your code.
  2. Raise an feature request with this project.
  1. This project uses tox to setup a development environment. Make sure you have tox installed:

    pip install tox
    
  2. Clone this repository

  3. You can setup the development environment by running the setup-dev make rule from the project directory:

    make setup-dev
    
  4. You can run tests by doing:

    make test
    
  5. To lint your code:

    make lint
    
  6. To format your code with Black run:

    make black
    

About

Fake uWSGI server for testing uwsgi

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors