Skip to main content

pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite

Project description


Latest PyPI version Documentation Status Wheel Status Supported Python Versions License

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

By default, pytest_pyramid will create two fixtures: pyramid_config, which creates configurator based on config.ini file, and pyramid_app, which creates TestApp based on Configurator returned by pyramid_config.

Command line options

  • –pc - pyramid configuration file based on which pytest_pyramid will create test app


For the most basic usage, pytest_pyramid provides 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.


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

Both of these fixtures depend on the Config file passed in the 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 pytest_pyramid.factories.

There are two factories:

  • pytest_pyramid.factories.pyramid_config provides you with Configuration object based on either settings, config_file argument, or by –pc command-line option config file.
  • pytest_pyramid.factories.pyramid_app creates a based on Configurator class instance as returned from fixture passed by name to it. It also accepts additional fixtures that should be loaded before the pyramid_app. See the example with postgresql below.
from pytest_postgresql.plugin import postgresql
from pytest_pyramid import factories

app_config = factories.pyramid_config(config_path="development.ini")
app_with_postgres = factories.pyramid_app("app_config", "postgresql")

def test_pyramid_app(app_with_postgres):
    res = app_with_postgres.get('/', status=404)
    assert res.status_code == 404


  1. provide a pyramid_proc fixture that will start pyramid app process using summon_process


To run tests run this command:

pytest –pc tests/pyramid.test.ini



  • [packaging] Defined entrypoint in setup.cfg


  • [breaking] Changed order of the fixture factory parameters
  • [breaking] Now, if config_path is given, it’ll always be loaded, with settings extending it’s configuration further.
  • [breaking] Support only python 3.8 and up
  • [enhancement] Updated packaging configuration
  • [enhancement] Typed all the code


  • add additiona_fixtures to factories.pyramid_app


  • add pyramid_config ini option


  • fixed pytest deprecation warning


  • [feature] changed pyramid_config fixture scope to session.


  • [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


  • make factories condition to check parameters against None


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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-pyramid, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pytest_pyramid-1.0.1-py3-none-any.whl (6.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pytest_pyramid-1.0.1.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page