Skip to content

Commit 139993b

Browse files
committed
Merge branch 'feature/image' of https://github.com/TSDV-VNU-API-Testing/schemathesis into feature/image
2 parents 4e774a1 + 4711c84 commit 139993b

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

src/schemathesis/cli/output/default.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
11
from __future__ import annotations
2+
23
import base64
34
import os
45
import platform
56
import shutil
67
import textwrap
78
import time
9+
from importlib import metadata
810
from itertools import groupby
911
from queue import Queue
1012
from typing import Any, Generator, cast
1113

1214
import click
13-
from importlib import metadata
1415

1516
from ... import service
1617
from ...code_samples import CodeSampleStyle
1718
from ...constants import (
1819
DISCORD_LINK,
20+
FALSE_VALUES,
1921
FLAKY_FAILURE_MESSAGE,
22+
GITHUB_APP_LINK,
23+
ISSUE_TRACKER_URL,
2024
REPORT_SUGGESTION_ENV_VAR,
2125
SCHEMATHESIS_TEST_CASE_HEADER,
2226
SCHEMATHESIS_VERSION,
23-
FALSE_VALUES,
24-
ISSUE_TRACKER_URL,
25-
GITHUB_APP_LINK,
2627
)
2728
from ...exceptions import RuntimeErrorType, prepare_response_payload
2829
from ...experimental import GLOBAL_EXPERIMENTS
2930
from ...models import Status
3031
from ...runner import events
3132
from ...runner.events import InternalErrorType, SchemaErrorType
3233
from ...runner.serialization import (
34+
SerializedCheck,
3335
SerializedError,
3436
SerializedTestResult,
3537
deduplicate_failures,
36-
SerializedCheck,
3738
)
39+
from ...specs.openapi._vas import logger
3840
from ..context import ExecutionContext, FileReportContext, ServiceReportContext
3941
from ..handlers import EventHandler
40-
from ...specs.openapi._vas import logger
4142

4243
SPINNER_REPETITION_NUMBER = 10
4344

@@ -532,7 +533,7 @@ def display_service_unauthorized(hostname: str) -> None:
532533

533534
def display_service_error(event: service.Error, message_prefix: str = "") -> None:
534535
"""Show information about an error during communication with Schemathesis.io."""
535-
from requests import RequestException, HTTPError, Response
536+
from requests import HTTPError, RequestException, Response
536537

537538
if isinstance(event.exception, HTTPError):
538539
response = cast(Response, event.exception.response)

src/schemathesis/models.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def as_requests_kwargs(
410410
"deps/schemathesis/src/schemathesis/models.py -> new extra: %s", new_extra
411411
)
412412

413-
additional_headers = extra.pop("headers", None)
413+
additional_headers = new_extra.pop("headers", None)
414414
if additional_headers:
415415
# Additional headers, needed for the serializer
416416
for key, value in additional_headers.items():
@@ -1062,7 +1062,10 @@ def from_case(cls, case: Case, session: requests.Session) -> Request:
10621062
@classmethod
10631063
def from_prepared_request(cls, prepared: requests.PreparedRequest) -> Request:
10641064
"""A prepared request version is already stored in `requests.Response`."""
1065-
logger.debug("deps/schemathesis/src/schemathesis/models.py: from_prepared_request in Request -> body: %s", prepared.body)
1065+
logger.debug(
1066+
"deps/schemathesis/src/schemathesis/models.py: from_prepared_request in Request -> body: %s",
1067+
prepared.body,
1068+
)
10661069
body = prepared.body
10671070
if isinstance(body, str):
10681071
# can be a string for `application/x-www-form-urlencoded`
@@ -1175,9 +1178,15 @@ def from_requests(
11751178
status: Status,
11761179
checks: list[Check],
11771180
) -> Interaction:
1178-
1179-
logger.debug("deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> response.request.body: %s", response.request.body)
1180-
logger.debug("deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> case.body: %s", case.body)
1181+
1182+
logger.debug(
1183+
"deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> response.request.body: %s",
1184+
response.request.body,
1185+
)
1186+
logger.debug(
1187+
"deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> case.body: %s",
1188+
case.body,
1189+
)
11811190
# new_request: Request = Request.from_prepared_request(response.request)
11821191
# if case.metadata is not None and new_request.body is not None:
11831192
# logger.debug("deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> request.body: %s", base64.b64decode(new_request.body))
@@ -1187,7 +1196,7 @@ def from_requests(
11871196
# case.body[key] = case.metadata[key]["image_name"]
11881197
# logger.debug("deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> %s", case.body)
11891198
# new_request.body = base64.b64encode(str(case.body).encode("utf-8")).decode("utf-8")
1190-
1199+
11911200
# Remove image data from the request body and replace it with the image name
11921201
# if new_request.body is not None:
11931202
# # logger.debug("deps/schemathesis/src/schemathesis/models.py: from_requests in Interaction -> %s", base64.b64decode(Request.from_prepared_request(response.request).body))

src/schemathesis/specs/openapi/_vas.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
from functools import partial
55

6+
from dotenv import dotenv_values as get_dotenv_values
67
from hypothesis import strategies as st
78

89
# from faker import Faker
@@ -30,7 +31,9 @@
3031
# from faker_file.providers.zip_file import ZipFileProvider
3132

3233

33-
DEV = True
34+
dotenv_values = get_dotenv_values(".env")
35+
PYTHON_ENV = dotenv_values.get("PYTHON_ENV", None)
36+
DEV = PYTHON_ENV != "PROD"
3437

3538
# FAKER = Faker()
3639

0 commit comments

Comments
 (0)