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)

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

Uploaded Source

Built Distribution

pytest_falcon-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest-falcon-0.1.2.tar.gz
Algorithm Hash digest
SHA256 611759f374f1a5d1ebb9020909cc9c9380f5dcab530b5c0046b62205811c9186
MD5 eb13500bc123d6ce8787f345f24d8124
BLAKE2b-256 d8df7c9b29a2982116a7d8698687cb2d11e8f08c5f2977e8130a7fdf0a1eb89d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_falcon-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0527ff18ee20c3ba0bfe84a71027c55f6abf712aff022383b309f9cc330e7e4e
MD5 6d0cc1f22f682861be0eb8e7ec535da2
BLAKE2b-256 022e7f2bc4aa73ddf98be19675f4ca6316a54da6eabd2c6052894c9a7acf7148

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