Skip to main content

Pytest helpers for Falcon.

Project description

[![Build Status](https://travis-ci.org/yohanboniface/pytest-falcon.svg?branch=master)](https://travis-ci.org/yohanboniface/pytest-falcon) [![Pypi version](https://img.shields.io/pypi/v/pytest-falcon.svg)](https://pypi.python.org/pypi/pytest-falcon)

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

```python
import falcon
import pytest


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


@pytest.fixture
def app():
return application
```

## Fixtures

### client

Allows you to test your API:

```python
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 = client.post('/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…)

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

pytest-falcon-0.4.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pytest_falcon-0.4.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-falcon-0.4.2.tar.gz.

File metadata

File hashes

Hashes for pytest-falcon-0.4.2.tar.gz
Algorithm Hash digest
SHA256 b196d169ad756cfae46b39c48196af5ebb6e3f7d3c2a5f59cd5979462dcf7dfa
MD5 a04be8da292dad1ae319048075e57647
BLAKE2b-256 efc57fb0173d814e7c7127a92b7060b9554751cabd28afec48eb5a18af4d7d6b

See more details on using hashes here.

File details

Details for the file pytest_falcon-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_falcon-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d4c54c89f6c83b0ef12db5dc4fd129c2255aeabb20467190696a57ffd9bde394
MD5 59d183679fb92dc9792fea6d90863727
BLAKE2b-256 9ab73ac18f19d8cf6a28b2d6f01536b63155afed08e4a76c4b4682feecfa5a22

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page