Skip to content

Commit

Permalink
fix: Passing workers_num to ThreadPoolRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed May 10, 2020
1 parent 7a76304 commit fbccd4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Expand Up @@ -12,6 +12,11 @@ Added
- New ``before_add_examples`` hook. `#571`_
- New ``after_init_cli_run_handlers`` hook. `#575`_

Fixed
~~~~~

- Passing ``workers_num`` to ``ThreadPoolRunner`` which lead to always using 2 workers in this worker kind. `#579`_

`1.5.1`_ - 2020-05-08
---------------------

Expand Down Expand Up @@ -1040,6 +1045,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

.. _#579: https://github.com/kiwicom/schemathesis/issues/579
.. _#575: https://github.com/kiwicom/schemathesis/issues/575
.. _#571: https://github.com/kiwicom/schemathesis/issues/571
.. _#566: https://github.com/kiwicom/schemathesis/issues/566
Expand Down
1 change: 1 addition & 0 deletions src/schemathesis/runner/__init__.py
Expand Up @@ -188,6 +188,7 @@ def execute_from_schema(
auth_type=auth_type,
headers=headers,
seed=seed,
workers_num=workers_num,
request_timeout=request_timeout,
exit_first=exit_first,
store_interactions=store_interactions,
Expand Down
10 changes: 9 additions & 1 deletion test/runner/test_runner.py
Expand Up @@ -15,7 +15,7 @@
from schemathesis.checks import content_type_conformance, response_schema_conformance, status_code_conformance
from schemathesis.constants import USER_AGENT
from schemathesis.models import Status
from schemathesis.runner import events, get_base_url, get_requests_auth, prepare
from schemathesis.runner import ThreadPoolRunner, events, get_base_url, get_requests_auth, prepare
from schemathesis.runner.impl.core import get_wsgi_auth


Expand Down Expand Up @@ -605,3 +605,11 @@ def test_reproduce_code_with_overridden_headers(args, base_url):
else:
expected = f"requests.get('{base_url}/api/failure', headers={headers})"
assert after.result.checks[1].example.requests_code == expected


@pytest.mark.endpoints("success")
def test_workers_num_regression(mocker, schema_url):
# GH: 579
spy = mocker.patch("schemathesis.runner.ThreadPoolRunner", wraps=ThreadPoolRunner)
execute(schema_url, workers_num=5)
assert spy.call_args[1]["workers_num"] == 5

0 comments on commit fbccd4a

Please sign in to comment.