From b0e21e20115791b7760b113071af154080c3ab15 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Tue, 14 Apr 2020 15:31:40 +0200 Subject: [PATCH] fix: Pass custom keyword arguments to `client.get` in the `from_wsgi` loader To match the behavior of `from_uri`. They should be the same, since they contact the application under test --- docs/changelog.rst | 2 ++ src/schemathesis/loaders.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index cb99506afa..2105a68aa6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,7 @@ Fixed ~~~~~ - Support for custom loaders in ``runner``. Now all built-in loaders are supported as an argument to ``runner.prepare``. `#496`_ +- ``from_wsgi`` loader accept custom keyword arguments that will be passed to ``client.get`` when accessing the schema. `#497`_ `1.1.1`_ - 2020-04-12 --------------------- @@ -897,6 +898,7 @@ Fixed .. _0.3.0: https://github.com/kiwicom/schemathesis/compare/v0.2.0...v0.3.0 .. _0.2.0: https://github.com/kiwicom/schemathesis/compare/v0.1.0...v0.2.0 +.. _#497: https://github.com/kiwicom/schemathesis/issues/497 .. _#496: https://github.com/kiwicom/schemathesis/issues/496 .. _#489: https://github.com/kiwicom/schemathesis/issues/489 .. _#473: https://github.com/kiwicom/schemathesis/issues/473 diff --git a/src/schemathesis/loaders.py b/src/schemathesis/loaders.py index b8b99737fc..53eedf7a87 100644 --- a/src/schemathesis/loaders.py +++ b/src/schemathesis/loaders.py @@ -171,8 +171,9 @@ def from_wsgi( validate_schema: bool = True, **kwargs: Any, ) -> BaseSchema: + kwargs.setdefault("headers", {}).setdefault("User-Agent", USER_AGENT) client = Client(app, WSGIResponse) - response = client.get(schema_path, headers={"User-Agent": USER_AGENT}) + response = client.get(schema_path, **kwargs) # Raising exception to provide unified behavior # E.g. it will be handled in CLI - a proper error message will be shown if 400 <= response.status_code < 600: