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-hypernode.com/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()

@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.3.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distributions

pytest_falcon-0.3.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

pytest_falcon-0.3.1-py2-none-any.whl (5.0 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for pytest-falcon-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f2eeb25fe48a785244aa38d1fac6cd6c8e9c6bae8505f3a849ae624ec5be7d56
MD5 16b73cf625fc77222a5afda5442c18fc
BLAKE2b-256 207ac226488bdc8d4ad64f46e7e346a7c8c734d047eaceddf9455ea66de01e04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_falcon-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88df3d64e5a3c4d4a1d1b5a863992ffdfbdccf4cfa52b5f894d4d77be1a9338c
MD5 f2536bbb78ef68bb4000a8060255f9a0
BLAKE2b-256 b42303915f0fb70679f33cac66ee262bd89cbc640d05c994cd3c7ae111db4058

See more details on using hashes here.

File details

Details for the file pytest_falcon-0.3.1-py2-none-any.whl.

File metadata

File hashes

Hashes for pytest_falcon-0.3.1-py2-none-any.whl
Algorithm Hash digest
SHA256 3fcb40da44ca5c5cd2734c93b22f9543c6b954b3250529ba212e90636c8d2a7d
MD5 7284379cfbe4e5e7047680332362d4cd
BLAKE2b-256 98315b90b8aa61c7fb8bc01b714b02949ef3699972bff6d250a744e2b413bdab

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