Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add documentation for using treq.testing to test klein applications #733

Open
betinacosta opened this issue Feb 22, 2024 · 1 comment
Open

Comments

@betinacosta
Copy link

With Flask you can do this:

class TestApp:
    @pytest.fixture
    def client(self):
        flask_app = app
        with flask_app.app.test_client() as client:
            yield client

But Klein app does not have a test_client or anything like it. Is there a way to test it?

@glyph
Copy link
Member

glyph commented Feb 28, 2024

You can use treq.testing for this, which is documented here: https://treq.readthedocs.io/en/release-22.1.0/testing.html#writing-tests-for-twisted-web-resources

While trying to answer this question, I was a bit surprised to find that there's nothing in Klein's docs that demonstrate putting this all together! I am going to repurpose this issue for the documentation improvement that suggests this approach.

@glyph glyph changed the title How to use pytest.fixture with Klein? add documentation for using treq.testing to test klein applications Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants