skip to navigation
skip to content

pytest-falcon 0.4.2

Pytest helpers for Falcon.

[![Build Status](]( [![Pypi version](](

# Pytest-Falcon

Pytest helpers for the Falcon framework.

## Install

pip install pytest-falcon

## Usage

You must create an `app` fixture to expose the Falcon application you want to test:

import falcon
import pytest

application = falcon.API()
application.req_options.auto_parse_form_urlencoded = True

def app():
return application

## Fixtures

### client

Allows you to test your API:

class Resource:

def on_post(self, req, resp, **kwargs):
resp.body = json.dumps(req.params)

application.add_route('/route', Resource())

def test_post(client):
resp ='/route', {'myparam': 'myvalue'})
assert resp.status == falcon.HTTP_OK
assert resp.json['myparam'] == 'myvalue'

Response properties:
- `body` the body as `str`
- `json` the body parsed as json when the response content-type is 'application/json'
- `headers` the response headers
- `status` the response status, as `str` ('200 OK', '405 Method Not Allowed'…)
- `status_code` the response status code, as `int` (200, 201…)  
File Type Py Version Uploaded on Size
pytest-falcon-0.4.2.tar.gz (md5) Source 2016-09-07 4KB
pytest_falcon-0.4.2-py3-none-any.whl (md5) Python Wheel 3.5 2016-09-07 5KB