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.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distributions

pytest_falcon-0.3.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

pytest_falcon-0.3.2-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for pytest-falcon-0.3.2.tar.gz
Algorithm Hash digest
SHA256 830838caf49a3317d600a055f54744593395bfae8d5d1ac10830043f97d5ae57
MD5 bf0ccd54e4f3a48b2ffd866e4def9332
BLAKE2b-256 d627da6038fa03a5b648d2e4fe27f3549cc593360bc16fe85e08168f6aa8132e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_falcon-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32cbe1798da2cae66230023e3b1ad6a575c30f2ff5180c2da0be11010069ef19
MD5 594a5e0bbfaa608e17f82866f69463a2
BLAKE2b-256 b6939687b2231c37c3a1a508280d78f4473cb9b27580ef3f0cff775519abafe0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_falcon-0.3.2-py2-none-any.whl
Algorithm Hash digest
SHA256 f878822c8cf9f9a26d8005ea2c3e5c12d291a70ec33847df9e876f489a66273c
MD5 107fcdb133ea91882c3f3a8e47a35592
BLAKE2b-256 f852fc57d214386a0ead381831df161c55b4084637e62eda9b141a00ed8260b2

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