pytest_pyramid

pytest_pyramid provides basic fixtures for testing pyramid applications with pytest test suite.

Usage

For the most basic usage pytest_pyramid provides a pyramid_app and pyramid_config fixtures, that can be used to test your pyramid app. Simply pass your pyramid config *.ini file to –pc command line option, and include pytest_app fixture into your test suite to be able to use it for integration tests.

Fixtures

pytest_pyramid provides two fixtures to be used in pytest tests:

  • pyramid_config - fixture providing pyramid’s Configurator instance as
    defined in pyramid config’s file
  • pyramid_app - pyramid application for testing - a webtest.app.TestApp

Both of these fixtures depend on Config file passed in command line.

Fixture factories

If you’re developing a module, package meant to extend functionalities of other applications, it’s not necessary to create a full blown application to test functionalities provided in packages. To do this, pytest_pyramid provides you with fixture factories.

There are two factories:

  • pyramid_config() provides you with Configuration object based on either settings, config_file argument or by –pc command line option config file.
  • pyramid_app() creates a TestApp based on Configurator class instance as returned from fixture passed by name to it.

API

All relevant code is placed in factories submodule

Pytest’s fixture factories.

pytest_pyramid.factories.pyramid_app(config_fixture_name)[source]

pyramid_app fixture factory.

Creates a TestApp instance based on.

Parameters:config_fixture_name (str) – name of a fixture creating pyramid.config.Configurator
Returns:TestApp based on pyramid’s COnfigurator object as returned from fixture passed by config_fixture_name
Return type:webtest.app.TestApp
pytest_pyramid.factories.pyramid_config(settings=None, config_path=None)[source]

A pyramid_config fixture factory.

Used to create aditional fixtures returning pyramid’s Configurator object.

Parameters:
  • settings (dict) – optional parameter delivering settings for building a Configurator object.
  • config_path (str) – optional parameter delivering path to pyramid configuration file
Returns:

configuration

Return type:

pyramid.config.Configurator

CHANGES

0.3.0

  • [feature] changed pyramid_config fixture scope to session.

0.2.0

  • [feature] support pyramid’s config inheritance with use = config:other.file.ini - Thanks Eric Hulser
  • [feature] dropped support for python 3.2, added support for python 3.4 and 3.5

0.1.1

  • make factories condition to check parameters against None

0.1.0

  • initial release
  • pyramid_config fixture factory and default fixture
  • pyramid_app fixture factory and default fixture
  • documentation

Authors

This file contains the list of people involved in the development of pytest_pyramid along its history.

  • Grzegorz Śliwiński
  • Eric Hulser

License

Copyright (c) 2014 by pytest_pyramid authors and contributors. See Authors

This module is part of pytest_pyramid and is released under the MIT License (MIT): http://opensource.org/licenses/MIT