Skip to content

Commit

Permalink
refactor: Remove unused schema argument from runner internals
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Apr 13, 2020
1 parent 39ebb42 commit 128ba24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/schemathesis/runner/impl/core.py
Expand Up @@ -62,7 +62,6 @@ def _execute(self, results: TestResultSet) -> Generator[events.ExecutionEvent, N


def run_test(
schema: BaseSchema,
endpoint: Endpoint,
test: Union[Callable, InvalidSchema],
checks: Iterable[CheckFunction],
Expand Down
17 changes: 2 additions & 15 deletions src/schemathesis/runner/impl/solo.py
Expand Up @@ -18,13 +18,7 @@ def _execute(self, results: TestResultSet) -> Generator[events.ExecutionEvent, N
with get_session(auth, self.headers) as session:
for endpoint, test in self.schema.get_all_tests(network_test, self.hypothesis_settings, self.seed):
for event in run_test(
self.schema,
endpoint,
test,
self.checks,
results,
session=session,
request_timeout=self.request_timeout,
endpoint, test, self.checks, results, session=session, request_timeout=self.request_timeout,
):
yield event
if isinstance(event, events.Interrupted):
Expand All @@ -36,14 +30,7 @@ class SingleThreadWSGIRunner(SingleThreadRunner):
def _execute(self, results: TestResultSet) -> Generator[events.ExecutionEvent, None, None]:
for endpoint, test in self.schema.get_all_tests(wsgi_test, self.hypothesis_settings, self.seed):
for event in run_test(
self.schema,
endpoint,
test,
self.checks,
results,
auth=self.auth,
auth_type=self.auth_type,
headers=self.headers,
endpoint, test, self.checks, results, auth=self.auth, auth_type=self.auth_type, headers=self.headers,
):
yield event
if isinstance(event, events.Interrupted):
Expand Down
14 changes: 3 additions & 11 deletions src/schemathesis/runner/impl/threadpool.py
Expand Up @@ -9,7 +9,6 @@

from ..._hypothesis import make_test_or_exception
from ...models import CheckFunction, TestResultSet
from ...schemas import BaseSchema
from ...types import RawAuth
from ...utils import capture_hypothesis_output, get_requests_auth
from .. import events
Expand All @@ -20,7 +19,6 @@ def _run_task(
test_template: Callable,
tasks_queue: Queue,
events_queue: Queue,
schema: BaseSchema,
checks: Iterable[CheckFunction],
settings: hypothesis.settings,
seed: Optional[int],
Expand All @@ -32,14 +30,13 @@ def _run_task(
while not tasks_queue.empty():
endpoint = tasks_queue.get()
test = make_test_or_exception(endpoint, test_template, settings, seed)
for event in run_test(schema, endpoint, test, checks, results, **kwargs):
for event in run_test(endpoint, test, checks, results, **kwargs):
events_queue.put(event)


def thread_task(
tasks_queue: Queue,
events_queue: Queue,
schema: BaseSchema,
checks: Iterable[CheckFunction],
settings: hypothesis.settings,
auth: Optional[RawAuth],
Expand All @@ -56,23 +53,20 @@ def thread_task(
# pylint: disable=too-many-arguments
prepared_auth = get_requests_auth(auth, auth_type)
with get_session(prepared_auth, headers) as session:
_run_task(
network_test, tasks_queue, events_queue, schema, checks, settings, seed, results, session=session, **kwargs
)
_run_task(network_test, tasks_queue, events_queue, checks, settings, seed, results, session=session, **kwargs)


def wsgi_thread_task(
tasks_queue: Queue,
events_queue: Queue,
schema: BaseSchema,
checks: Iterable[CheckFunction],
settings: hypothesis.settings,
seed: Optional[int],
results: TestResultSet,
kwargs: Any,
) -> None:
# pylint: disable=too-many-arguments
_run_task(wsgi_test, tasks_queue, events_queue, schema, checks, settings, seed, results, **kwargs)
_run_task(wsgi_test, tasks_queue, events_queue, checks, settings, seed, results, **kwargs)


def stop_worker(thread_id: int) -> None:
Expand Down Expand Up @@ -147,7 +141,6 @@ def _get_worker_kwargs(self, tasks_queue: Queue, events_queue: Queue, results: T
return {
"tasks_queue": tasks_queue,
"events_queue": events_queue,
"schema": self.schema,
"checks": self.checks,
"settings": self.hypothesis_settings,
"auth": self.auth,
Expand All @@ -167,7 +160,6 @@ def _get_worker_kwargs(self, tasks_queue: Queue, events_queue: Queue, results: T
return {
"tasks_queue": tasks_queue,
"events_queue": events_queue,
"schema": self.schema,
"checks": self.checks,
"settings": self.hypothesis_settings,
"seed": self.seed,
Expand Down

0 comments on commit 128ba24

Please sign in to comment.