Skip to main content
https://raw.githubusercontent.com/fizyk/pytest_pyramid/master/logo.png

pytest_pyramid

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

Usage

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.

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 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 webtest.app.TestApp 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

TODO

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

Tests

To run tests run this command:

pytest –pc tests/pyramid.test.ini

CHANGES

1.0.0

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

0.3.3

  • add additiona_fixtures to factories.pyramid_app

0.3.2

  • add pyramid_config ini option

0.3.1

  • fixed pytest deprecation warning

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

Metadata

Release files for pytest-pyramid 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-pyramid 1.0.0
File Size Uploaded
pytest_pyramid-1.0.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-pyramid 1.0.0
File Interpreter ABI Platform
pytest_pyramid-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / pytest_pyramid-1.0.0.tar.gz

Download URL pytest_pyramid-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a443ac804ccd2e64b2006637facf2af54a033d319443a9afcff06b289c0cd858
BLAKE2b-256 checksum
How to use checksums
0ef35b4e9c7cab8c3dbe830b7f890ebcf668975c69b6a55782675bd26c5da2e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release files / pytest_pyramid-1.0.0-py3-none-any.whl

Download URL pytest_pyramid-1.0.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
480dc1e0ddbc17eaea7d01c4c40a8113399642b1813ca449aad5477d9dd11b92
BLAKE2b-256 checksum
How to use checksums
c74d4bb639aa0d130635be5d52f7735ee33931c701d35085c4dd56d5a5d845af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release history Release notifications | RSS feed

2.0.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

This release

1.0.0 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page