Skip to content

Repository files navigation

Build StatusPypi 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:

importfalconimportpytestapplication=falcon.API()
@pytest.fixturedefapp():
returnapplication

Fixtures

client

Allows you to test your API:

classResource:
defon_post(self, req, resp, **kwargs):
resp.body=json.dumps(req.params)
application.add_route('/route', Resource())
deftest_post(client):
resp=client.post('/route', {'myparam': 'myvalue'})
assertresp.status==falcon.HTTP_OKassertresp.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…)

About

Pytest helpers for testing Falcon applications

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages