Skip to main content

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

Project description

https://raw.githubusercontent.com/fizyk/pytest_pyramid/master/logo.png

pytest_pyramid

Latest PyPI version 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

Release

Install pipenv and –dev dependencies first, Then run:

pipenv run tbump [NEW_VERSION]

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_pyramid-1.0.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

pytest_pyramid-1.0.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_pyramid-1.0.2.tar.gz.

File metadata

  • Download URL: pytest_pyramid-1.0.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pytest_pyramid-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8b3cfdabcac1b3632c91d7f9027bad1cc5acc93196d6dc43d68733f9d54a48ff
MD5 4d906075e46174face41c6f9bed02ede
BLAKE2b-256 2082b83c3ece75f3528e69fb33bd21bd5dd63eeec38d2e0a373f778e321d2ab5

See more details on using hashes here.

File details

Details for the file pytest_pyramid-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_pyramid-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 947ae8d268a2fec200f29c6da8baa4f43b50dbc0e7db10d21a1374f3b02cec51
MD5 c46d1a636742bca610512488b2d30e63
BLAKE2b-256 73e56262523d1deaa63c80e8d24485fe7dd738c28f07facda9f9110ee301864b

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