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 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.1

  • [packaging] Defined entrypoint in setup.cfg

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

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.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

pytest_pyramid-1.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_pyramid-1.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pytest_pyramid-1.0.1.tar.gz
Algorithm Hash digest
SHA256 094b28b8df903176ca0fb600c4256932cc131938433e1ea70507de42e8ed0dc1
MD5 6535ea3832ea4560e76952126ad84d3d
BLAKE2b-256 e070192836fb11948851e30c685fc14c3eb3f6f3c1a6fd34e8ae95fd49a9429d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_pyramid-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pytest_pyramid-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2a32f7387825d2da3c9af347cb4028495c83e5924ee081b0d76093e5433777
MD5 6f5c9fc42f2e325c6bbf8c0ec4a8ebb2
BLAKE2b-256 68f3f350d5c1eb5155b80ae1781bebb6e5dcdbe50d041af4f7d23314272aa993

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