pytest + webtest + pyramid

How to functionally test an application developed with pyramid with WebTest is described in here. When I try to run this test with pytest, it doesn't work. As stated in the original documentation. pytest may not include your tests.

Also, when I read the pytest documentation, I feel like using ʻunittest` doesn't work. For example, the special parametrized test does not work if the test class is a subclass of unittest (http://stackoverflow.com/questions/18182251/does-pytest-parametrized-test-work-with-unittest- class-based-tests).

That's why the configuration for testing the pyramid app with pytest + webtest looks like this.

conftest.py


import pytest

def pytest_report_header(config):
    return "sample: functional tests"

@pytest.fixture
def app():
    """ prepare test target app """
    from app import main
    main_app = main({})
    from webtest import TestApp
    return TestApp(main_app)

tests.py


import pytest

@pytest.mark.usefixtures("app")
def test_not_found(app):
    res = app.get('/', status=404)
Omitted below

Finally, I feel like I can write a test with pytest. I think the parametrized test is the most convenient.

reference

Recommended Posts

pytest + webtest + pyramid
pytest
pyramid
pytest memo
pytest summary
Introduced Pyramid