Use relative imports (#1057)

* Use relative imports in test

* Use relative imports

* Add myself to contributors :)
This commit is contained in:
Mickaël Schoentgen 2021-05-05 14:13:39 +02:00 committed by GitHub
parent 7cbdf2c608
commit a3a08a9a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 118 additions and 118 deletions

View File

@ -39,5 +39,6 @@ Patches and ideas
* `Aleksandr Vinokurov <https://github.com/aleksandr-vin>`_ * `Aleksandr Vinokurov <https://github.com/aleksandr-vin>`_
* `Jeff Byrnes <https://github.com/jeffbyrnes>`_ * `Jeff Byrnes <https://github.com/jeffbyrnes>`_
* `Denis Belavin <https://github.com/LuckyDenis>`_ * `Denis Belavin <https://github.com/LuckyDenis>`_
* `Mickaël Schoentgen <https://github.com/BoboTiG>`_

View File

@ -7,7 +7,7 @@ import sys
def main(): def main():
try: try:
from .core import main from httpie.core import main
exit_status = main() exit_status = main()
except KeyboardInterrupt: except KeyboardInterrupt:
from httpie.status import ExitStatus from httpie.status import ExitStatus

View File

@ -9,23 +9,23 @@ from urllib.parse import urlsplit
from requests.utils import get_netrc_auth from requests.utils import get_netrc_auth
from httpie.cli.argtypes import ( from .argtypes import (
AuthCredentials, KeyValueArgType, PARSED_DEFAULT_FORMAT_OPTIONS, AuthCredentials, KeyValueArgType, PARSED_DEFAULT_FORMAT_OPTIONS,
parse_auth, parse_auth,
parse_format_options, parse_format_options,
) )
from httpie.cli.constants import ( from .constants import (
HTTP_GET, HTTP_POST, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT, HTTP_GET, HTTP_POST, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT,
OUTPUT_OPTIONS_DEFAULT_OFFLINE, OUTPUT_OPTIONS_DEFAULT_STDOUT_REDIRECTED, OUTPUT_OPTIONS_DEFAULT_OFFLINE, OUTPUT_OPTIONS_DEFAULT_STDOUT_REDIRECTED,
OUT_RESP_BODY, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, RequestType, OUT_RESP_BODY, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, RequestType,
SEPARATOR_CREDENTIALS, SEPARATOR_CREDENTIALS,
SEPARATOR_GROUP_ALL_ITEMS, SEPARATOR_GROUP_DATA_ITEMS, URL_SCHEME_RE, SEPARATOR_GROUP_ALL_ITEMS, SEPARATOR_GROUP_DATA_ITEMS, URL_SCHEME_RE,
) )
from httpie.cli.exceptions import ParseError from .exceptions import ParseError
from httpie.cli.requestitems import RequestItems from .requestitems import RequestItems
from httpie.context import Environment from ..context import Environment
from httpie.plugins.registry import plugin_manager from ..plugins.registry import plugin_manager
from httpie.utils import ExplicitNullAuth, get_content_type from ..utils import ExplicitNullAuth, get_content_type
class HTTPieHelpFormatter(RawDescriptionHelpFormatter): class HTTPieHelpFormatter(RawDescriptionHelpFormatter):

View File

@ -5,8 +5,8 @@ import sys
from copy import deepcopy from copy import deepcopy
from typing import List, Optional, Union from typing import List, Optional, Union
from httpie.cli.constants import DEFAULT_FORMAT_OPTIONS, SEPARATOR_CREDENTIALS from .constants import DEFAULT_FORMAT_OPTIONS, SEPARATOR_CREDENTIALS
from httpie.sessions import VALID_SESSION_NAME_PATTERN from ..sessions import VALID_SESSION_NAME_PATTERN
class KeyValueArg: class KeyValueArg:

View File

@ -5,13 +5,13 @@ CLI arguments definition.
from argparse import (FileType, OPTIONAL, SUPPRESS, ZERO_OR_MORE) from argparse import (FileType, OPTIONAL, SUPPRESS, ZERO_OR_MORE)
from textwrap import dedent, wrap from textwrap import dedent, wrap
from httpie import __doc__, __version__ from .. import __doc__, __version__
from httpie.cli.argparser import HTTPieArgumentParser from .argparser import HTTPieArgumentParser
from httpie.cli.argtypes import ( from .argtypes import (
KeyValueArgType, SessionNameValidator, KeyValueArgType, SessionNameValidator,
readable_file_arg, readable_file_arg,
) )
from httpie.cli.constants import ( from .constants import (
DEFAULT_FORMAT_OPTIONS, OUTPUT_OPTIONS, DEFAULT_FORMAT_OPTIONS, OUTPUT_OPTIONS,
OUTPUT_OPTIONS_DEFAULT, OUT_REQ_BODY, OUT_REQ_HEAD, OUTPUT_OPTIONS_DEFAULT, OUT_REQ_BODY, OUT_REQ_HEAD,
OUT_RESP_BODY, OUT_RESP_HEAD, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, OUT_RESP_BODY, OUT_RESP_HEAD, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY,
@ -19,13 +19,13 @@ from httpie.cli.constants import (
SORTED_FORMAT_OPTIONS_STRING, SORTED_FORMAT_OPTIONS_STRING,
UNSORTED_FORMAT_OPTIONS_STRING, UNSORTED_FORMAT_OPTIONS_STRING,
) )
from httpie.output.formatters.colors import ( from ..output.formatters.colors import (
AUTO_STYLE, AVAILABLE_STYLES, DEFAULT_STYLE, AUTO_STYLE, AVAILABLE_STYLES, DEFAULT_STYLE,
) )
from httpie.plugins.builtin import BuiltinAuthPlugin from ..plugins.builtin import BuiltinAuthPlugin
from httpie.plugins.registry import plugin_manager from ..plugins.registry import plugin_manager
from httpie.sessions import DEFAULT_SESSIONS_DIR from ..sessions import DEFAULT_SESSIONS_DIR
from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, DEFAULT_SSL_CIPHERS from ..ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, DEFAULT_SSL_CIPHERS
parser = HTTPieArgumentParser( parser = HTTPieArgumentParser(

View File

@ -1,21 +1,21 @@
import os import os
from typing import Callable, Dict, IO, List, Optional, Tuple, Union from typing import Callable, Dict, IO, List, Optional, Tuple, Union
from httpie.cli.argtypes import KeyValueArg from .argtypes import KeyValueArg
from httpie.cli.constants import ( from .constants import (
SEPARATORS_GROUP_MULTIPART, SEPARATOR_DATA_EMBED_FILE_CONTENTS, SEPARATORS_GROUP_MULTIPART, SEPARATOR_DATA_EMBED_FILE_CONTENTS,
SEPARATOR_DATA_EMBED_RAW_JSON_FILE, SEPARATOR_DATA_EMBED_RAW_JSON_FILE,
SEPARATOR_DATA_RAW_JSON, SEPARATOR_DATA_STRING, SEPARATOR_FILE_UPLOAD, SEPARATOR_DATA_RAW_JSON, SEPARATOR_DATA_STRING, SEPARATOR_FILE_UPLOAD,
SEPARATOR_FILE_UPLOAD_TYPE, SEPARATOR_HEADER, SEPARATOR_HEADER_EMPTY, SEPARATOR_FILE_UPLOAD_TYPE, SEPARATOR_HEADER, SEPARATOR_HEADER_EMPTY,
SEPARATOR_QUERY_PARAM, SEPARATOR_QUERY_PARAM,
) )
from httpie.cli.dicts import ( from .dicts import (
MultipartRequestDataDict, RequestDataDict, RequestFilesDict, MultipartRequestDataDict, RequestDataDict, RequestFilesDict,
RequestHeadersDict, RequestJSONDataDict, RequestHeadersDict, RequestJSONDataDict,
RequestQueryParamsDict, RequestQueryParamsDict,
) )
from httpie.cli.exceptions import ParseError from .exceptions import ParseError
from httpie.utils import (get_content_type, load_json_preserve_order) from ..utils import get_content_type, load_json_preserve_order
class RequestItems: class RequestItems:

View File

@ -10,16 +10,16 @@ from urllib.parse import urlparse, urlunparse
import requests import requests
# noinspection PyPackageRequirements # noinspection PyPackageRequirements
import urllib3 import urllib3
from httpie import __version__ from . import __version__
from httpie.cli.dicts import RequestHeadersDict from .cli.dicts import RequestHeadersDict
from httpie.plugins.registry import plugin_manager from .plugins.registry import plugin_manager
from httpie.sessions import get_httpie_session from .sessions import get_httpie_session
from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, HTTPieHTTPSAdapter from .ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, HTTPieHTTPSAdapter
from httpie.uploads import ( from .uploads import (
compress_request, prepare_request_body, compress_request, prepare_request_body,
get_multipart_data_and_content_type, get_multipart_data_and_content_type,
) )
from httpie.utils import get_expired_cookies, repr_dict from .utils import get_expired_cookies, repr_dict
urllib3.disable_warnings() urllib3.disable_warnings()

View File

@ -4,8 +4,8 @@ import os
from pathlib import Path from pathlib import Path
from typing import Union from typing import Union
from httpie import __version__ from . import __version__
from httpie.compat import is_windows from .compat import is_windows
ENV_XDG_CONFIG_HOME = 'XDG_CONFIG_HOME' ENV_XDG_CONFIG_HOME = 'XDG_CONFIG_HOME'

View File

@ -9,10 +9,10 @@ try:
except ImportError: except ImportError:
curses = None # Compiled w/o curses curses = None # Compiled w/o curses
from httpie.compat import is_windows from .compat import is_windows
from httpie.config import DEFAULT_CONFIG_DIR, Config, ConfigFileError from .config import DEFAULT_CONFIG_DIR, Config, ConfigFileError
from httpie.utils import repr_dict from .utils import repr_dict
class Environment: class Environment:

View File

@ -8,14 +8,14 @@ import requests
from pygments import __version__ as pygments_version from pygments import __version__ as pygments_version
from requests import __version__ as requests_version from requests import __version__ as requests_version
from httpie import __version__ as httpie_version from . import __version__ as httpie_version
from httpie.cli.constants import OUT_REQ_BODY, OUT_REQ_HEAD, OUT_RESP_BODY, OUT_RESP_HEAD from .cli.constants import OUT_REQ_BODY, OUT_REQ_HEAD, OUT_RESP_BODY, OUT_RESP_HEAD
from httpie.client import collect_messages from .client import collect_messages
from httpie.context import Environment from .context import Environment
from httpie.downloads import Downloader from .downloads import Downloader
from httpie.output.writer import write_message, write_stream, MESSAGE_SEPARATOR_BYTES from .output.writer import write_message, write_stream, MESSAGE_SEPARATOR_BYTES
from httpie.plugins.registry import plugin_manager from .plugins.registry import plugin_manager
from httpie.status import ExitStatus, http_status_to_exit_status from .status import ExitStatus, http_status_to_exit_status
# noinspection PyDefaultArgument # noinspection PyDefaultArgument
@ -34,7 +34,7 @@ def main(args: List[Union[str, bytes]] = sys.argv, env=Environment()) -> ExitSta
args = decode_raw_args(args, env.stdin_encoding) args = decode_raw_args(args, env.stdin_encoding)
plugin_manager.load_installed_plugins() plugin_manager.load_installed_plugins()
from httpie.cli.definition import parser from .cli.definition import parser
if env.config.default_options: if env.config.default_options:
args = env.config.default_options + args args = env.config.default_options + args

View File

@ -18,9 +18,9 @@ from urllib.parse import urlsplit
import requests import requests
from httpie.models import HTTPResponse from .models import HTTPResponse
from httpie.output.streams import RawStream from .output.streams import RawStream
from httpie.utils import humanize_bytes from .utils import humanize_bytes
PARTIAL_CONTENT = 206 PARTIAL_CONTENT = 206

View File

@ -15,9 +15,9 @@ from pygments.lexers.special import TextLexer
from pygments.lexers.text import HttpLexer as PygmentsHttpLexer from pygments.lexers.text import HttpLexer as PygmentsHttpLexer
from pygments.util import ClassNotFound from pygments.util import ClassNotFound
from httpie.compat import is_windows from ...compat import is_windows
from httpie.context import Environment from ...context import Environment
from httpie.plugins import FormatterPlugin from ...plugins import FormatterPlugin
AUTO_STYLE = 'auto' # Follows terminal ANSI color styles AUTO_STYLE = 'auto' # Follows terminal ANSI color styles

View File

@ -1,4 +1,4 @@
from httpie.plugins import FormatterPlugin from ...plugins import FormatterPlugin
class HeadersFormatter(FormatterPlugin): class HeadersFormatter(FormatterPlugin):

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import from __future__ import absolute_import
import json import json
from httpie.plugins import FormatterPlugin from ...plugins import FormatterPlugin
class JSONFormatter(FormatterPlugin): class JSONFormatter(FormatterPlugin):

View File

@ -1,9 +1,9 @@
import re import re
from typing import Optional, List from typing import Optional, List
from httpie.plugins import ConverterPlugin from ..plugins import ConverterPlugin
from httpie.plugins.registry import plugin_manager from ..plugins.registry import plugin_manager
from httpie.context import Environment from ..context import Environment
MIME_RE = re.compile(r'^[^/]+/[^/]+$') MIME_RE = re.compile(r'^[^/]+/[^/]+$')

View File

@ -1,9 +1,9 @@
from itertools import chain from itertools import chain
from typing import Callable, Iterable, Union from typing import Callable, Iterable, Union
from httpie.context import Environment from ..context import Environment
from httpie.models import HTTPMessage from ..models import HTTPMessage
from httpie.output.processing import Conversion, Formatting from .processing import Conversion, Formatting
BINARY_SUPPRESSED_NOTICE = ( BINARY_SUPPRESSED_NOTICE = (

View File

@ -4,10 +4,10 @@ from typing import IO, TextIO, Tuple, Type, Union
import requests import requests
from httpie.context import Environment from ..context import Environment
from httpie.models import HTTPRequest, HTTPResponse from ..models import HTTPRequest, HTTPResponse
from httpie.output.processing import Conversion, Formatting from .processing import Conversion, Formatting
from httpie.output.streams import ( from .streams import (
BaseStream, BufferedPrettyStream, EncodedStream, PrettyStream, RawStream, BaseStream, BufferedPrettyStream, EncodedStream, PrettyStream, RawStream,
) )

View File

@ -3,7 +3,7 @@ WARNING: The plugin API is still work in progress and will
probably be completely reworked in the future. probably be completely reworked in the future.
""" """
from httpie.plugins.base import ( from .base import (
AuthPlugin, FormatterPlugin, AuthPlugin, FormatterPlugin,
ConverterPlugin, TransportPlugin ConverterPlugin, TransportPlugin
) )

View File

@ -2,7 +2,7 @@ from base64 import b64encode
import requests.auth import requests.auth
from httpie.plugins.base import AuthPlugin from .base import AuthPlugin
# noinspection PyAbstractClass # noinspection PyAbstractClass

View File

@ -4,8 +4,8 @@ from typing import Dict, List, Type
from pkg_resources import iter_entry_points from pkg_resources import iter_entry_points
from httpie.plugins import AuthPlugin, ConverterPlugin, FormatterPlugin from . import AuthPlugin, ConverterPlugin, FormatterPlugin
from httpie.plugins.base import BasePlugin, TransportPlugin from .base import BasePlugin, TransportPlugin
ENTRY_POINT_NAMES = [ ENTRY_POINT_NAMES = [

View File

@ -1,8 +1,8 @@
from httpie.plugins.manager import PluginManager from .manager import PluginManager
from httpie.plugins.builtin import BasicAuthPlugin, DigestAuthPlugin from .builtin import BasicAuthPlugin, DigestAuthPlugin
from httpie.output.formatters.headers import HeadersFormatter from ..output.formatters.headers import HeadersFormatter
from httpie.output.formatters.json import JSONFormatter from ..output.formatters.json import JSONFormatter
from httpie.output.formatters.colors import ColorFormatter from ..output.formatters.colors import ColorFormatter
plugin_manager = PluginManager() plugin_manager = PluginManager()

View File

@ -13,9 +13,9 @@ from urllib.parse import urlsplit
from requests.auth import AuthBase from requests.auth import AuthBase
from requests.cookies import RequestsCookieJar, create_cookie from requests.cookies import RequestsCookieJar, create_cookie
from httpie.cli.dicts import RequestHeadersDict from .cli.dicts import RequestHeadersDict
from httpie.config import BaseConfigDict, DEFAULT_CONFIG_DIR from .config import BaseConfigDict, DEFAULT_CONFIG_DIR
from httpie.plugins.registry import plugin_manager from .plugins.registry import plugin_manager
SESSIONS_DIR_NAME = 'sessions' SESSIONS_DIR_NAME = 'sessions'
@ -141,7 +141,7 @@ class Session(BaseConfigDict):
} }
else: else:
if plugin.auth_parse: if plugin.auth_parse:
from httpie.cli.argtypes import parse_auth from .cli.argtypes import parse_auth
parsed = parse_auth(plugin.raw_auth) parsed = parse_auth(plugin.raw_auth)
credentials = { credentials = {
'username': parsed.key, 'username': parsed.key,

View File

@ -6,7 +6,7 @@ import requests
from requests.utils import super_len from requests.utils import super_len
from requests_toolbelt import MultipartEncoder from requests_toolbelt import MultipartEncoder
from httpie.cli.dicts import MultipartRequestDataDict, RequestDataDict from .cli.dicts import MultipartRequestDataDict, RequestDataDict
class ChunkedUploadStream: class ChunkedUploadStream:

0
tests/__init__.py Normal file
View File

View File

@ -5,7 +5,7 @@ import pytest
from httpie.plugins.builtin import HTTPBasicAuth from httpie.plugins.builtin import HTTPBasicAuth
from httpie.status import ExitStatus from httpie.status import ExitStatus
from httpie.utils import ExplicitNullAuth from httpie.utils import ExplicitNullAuth
from utils import http, add_auth, HTTP_OK, MockEnvironment from .utils import http, add_auth, HTTP_OK, MockEnvironment
import httpie.cli.constants import httpie.cli.constants
import httpie.cli.definition import httpie.cli.definition

View File

@ -3,7 +3,7 @@ from unittest import mock
from httpie.cli.constants import SEPARATOR_CREDENTIALS from httpie.cli.constants import SEPARATOR_CREDENTIALS
from httpie.plugins import AuthPlugin from httpie.plugins import AuthPlugin
from httpie.plugins.registry import plugin_manager from httpie.plugins.registry import plugin_manager
from utils import http, HTTP_OK from .utils import http, HTTP_OK
# TODO: run all these tests in session mode as well # TODO: run all these tests in session mode as well

View File

@ -1,9 +1,9 @@
"""Tests for dealing with binary request and response data.""" """Tests for dealing with binary request and response data."""
import requests import requests
from fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG from .fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG
from httpie.output.streams import BINARY_SUPPRESSED_NOTICE from httpie.output.streams import BINARY_SUPPRESSED_NOTICE
from utils import MockEnvironment, http from .utils import MockEnvironment, http
class TestBinaryRequestData: class TestBinaryRequestData:

View File

@ -6,7 +6,7 @@ import pytest
from requests.exceptions import InvalidSchema from requests.exceptions import InvalidSchema
import httpie.cli.argparser import httpie.cli.argparser
from fixtures import ( from .fixtures import (
FILE_CONTENT, FILE_PATH, FILE_PATH_ARG, JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH, FILE_PATH_ARG, JSON_FILE_CONTENT,
JSON_FILE_PATH_ARG, JSON_FILE_PATH_ARG,
) )
@ -15,7 +15,7 @@ from httpie.cli import constants
from httpie.cli.definition import parser from httpie.cli.definition import parser
from httpie.cli.argtypes import KeyValueArg, KeyValueArgType from httpie.cli.argtypes import KeyValueArg, KeyValueArgType
from httpie.cli.requestitems import RequestItems from httpie.cli.requestitems import RequestItems
from utils import HTTP_OK, MockEnvironment, StdinBytesIO, http from .utils import HTTP_OK, MockEnvironment, StdinBytesIO, http
class TestItemParsing: class TestItemParsing:

View File

@ -11,9 +11,9 @@ our zlib-encoded request data.
import base64 import base64
import zlib import zlib
from fixtures import FILE_PATH, FILE_CONTENT from .fixtures import FILE_PATH, FILE_CONTENT
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import StdinBytesIO, http, HTTP_OK, MockEnvironment from .utils import StdinBytesIO, http, HTTP_OK, MockEnvironment
def assert_decompressed_equal(base64_compressed_data, expected_str): def assert_decompressed_equal(base64_compressed_data, expected_str):

View File

@ -9,7 +9,7 @@ from httpie.config import (
DEFAULT_RELATIVE_XDG_CONFIG_HOME, DEFAULT_WINDOWS_CONFIG_DIR, DEFAULT_RELATIVE_XDG_CONFIG_HOME, DEFAULT_WINDOWS_CONFIG_DIR,
ENV_HTTPIE_CONFIG_DIR, ENV_XDG_CONFIG_HOME, get_default_config_dir, ENV_HTTPIE_CONFIG_DIR, ENV_XDG_CONFIG_HOME, get_default_config_dir,
) )
from utils import HTTP_OK, MockEnvironment, http from .utils import HTTP_OK, MockEnvironment, http
def test_default_options(httpbin): def test_default_options(httpbin):

View File

@ -5,8 +5,8 @@ Tests for the provided defaults regarding HTTP method, and --json vs. --form.
from io import BytesIO from io import BytesIO
from httpie.client import JSON_ACCEPT from httpie.client import JSON_ACCEPT
from utils import MockEnvironment, http, HTTP_OK from .utils import MockEnvironment, http, HTTP_OK
from fixtures import FILE_PATH from .fixtures import FILE_PATH
def test_default_headers_case_insensitive(httpbin): def test_default_headers_case_insensitive(httpbin):

View File

@ -5,7 +5,7 @@ from pathlib import Path
import pytest import pytest
from utils import TESTS_ROOT from .utils import TESTS_ROOT
SOURCE_DIRECTORIES = [ SOURCE_DIRECTORIES = [

View File

@ -11,7 +11,7 @@ from httpie.downloads import (
parse_content_range, filename_from_content_disposition, filename_from_url, parse_content_range, filename_from_content_disposition, filename_from_url,
get_unique_filename, ContentRangeError, Downloader, get_unique_filename, ContentRangeError, Downloader,
) )
from utils import http, MockEnvironment from .utils import http, MockEnvironment
class Response: class Response:

View File

@ -4,7 +4,7 @@ from requests import Request
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import HTTP_OK, http from .utils import HTTP_OK, http
@mock.patch('httpie.core.program') @mock.patch('httpie.core.program')

View File

@ -1,7 +1,7 @@
from unittest import mock from unittest import mock
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import MockEnvironment, http, HTTP_OK from .utils import MockEnvironment, http, HTTP_OK
def test_keyboard_interrupt_during_arg_parsing_exit_status(httpbin): def test_keyboard_interrupt_during_arg_parsing_exit_status(httpbin):

View File

@ -6,11 +6,11 @@ import pytest
import httpie import httpie
import httpie.__main__ import httpie.__main__
from fixtures import FILE_CONTENT, FILE_PATH from .fixtures import FILE_CONTENT, FILE_PATH
from httpie.cli.exceptions import ParseError from httpie.cli.exceptions import ParseError
from httpie.context import Environment from httpie.context import Environment
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import HTTP_OK, MockEnvironment, StdinBytesIO, http from .utils import HTTP_OK, MockEnvironment, StdinBytesIO, http
def test_main_entry_point(): def test_main_entry_point():

View File

@ -1,5 +1,5 @@
from fixtures import FILE_CONTENT, FILE_PATH_ARG from .fixtures import FILE_CONTENT, FILE_PATH_ARG
from utils import http from .utils import http
def test_offline(): def test_offline():

View File

@ -19,7 +19,7 @@ from httpie.cli.argtypes import (
from httpie.cli.definition import parser from httpie.cli.definition import parser
from httpie.output.formatters.colors import get_lexer from httpie.output.formatters.colors import get_lexer
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import COLOR, CRLF, HTTP_OK, MockEnvironment, http from .utils import COLOR, CRLF, HTTP_OK, MockEnvironment, http
@pytest.mark.parametrize('stdout_isatty', [True, False]) @pytest.mark.parametrize('stdout_isatty', [True, False])

View File

@ -2,7 +2,7 @@
import pytest import pytest
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import http, HTTP_OK from .utils import http, HTTP_OK
def test_follow_all_redirects_shown(httpbin): def test_follow_all_redirects_shown(httpbin):

View File

@ -2,8 +2,8 @@
import pytest import pytest
from httpie.compat import is_windows from httpie.compat import is_windows
from tests.utils.matching import assert_output_matches, Expect from .utils.matching import assert_output_matches, Expect
from utils import HTTP_OK, MockEnvironment, http from .utils import HTTP_OK, MockEnvironment, http
def test_Host_header_overwrite(httpbin): def test_Host_header_overwrite(httpbin):

View File

@ -8,15 +8,14 @@ from tempfile import gettempdir
import pytest import pytest
from fixtures import UNICODE from .fixtures import FILE_PATH_ARG, UNICODE
from httpie.plugins import AuthPlugin from httpie.plugins import AuthPlugin
from httpie.plugins.builtin import HTTPBasicAuth from httpie.plugins.builtin import HTTPBasicAuth
from httpie.plugins.registry import plugin_manager from httpie.plugins.registry import plugin_manager
from httpie.sessions import Session from httpie.sessions import Session
from httpie.utils import get_expired_cookies from httpie.utils import get_expired_cookies
from tests.test_auth_plugins import basic_auth from .test_auth_plugins import basic_auth
from utils import HTTP_OK, MockEnvironment, http, mk_config_dir from .utils import HTTP_OK, MockEnvironment, http, mk_config_dir
from fixtures import FILE_PATH_ARG
class SessionTestBase: class SessionTestBase:

View File

@ -6,7 +6,7 @@ import urllib3
from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, DEFAULT_SSL_CIPHERS from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, DEFAULT_SSL_CIPHERS
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import HTTP_OK, TESTS_ROOT, http from .utils import HTTP_OK, TESTS_ROOT, http
try: try:

View File

@ -2,8 +2,8 @@ import pytest
from httpie.compat import is_windows from httpie.compat import is_windows
from httpie.output.streams import BINARY_SUPPRESSED_NOTICE from httpie.output.streams import BINARY_SUPPRESSED_NOTICE
from utils import StdinBytesIO, http, MockEnvironment from .utils import StdinBytesIO, http, MockEnvironment
from fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH from .fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH
# GET because httpbin 500s with binary POST body. # GET because httpbin 500s with binary POST body.

View File

@ -9,8 +9,8 @@ TODO: cover more scenarios
* streamed uploads * streamed uploads
""" """
from tests.utils.matching import assert_output_matches, Expect from .utils.matching import assert_output_matches, Expect
from utils import http, HTTP_OK, MockEnvironment, HTTPBIN_WITH_CHUNKED_SUPPORT from .utils import http, HTTP_OK, MockEnvironment, HTTPBIN_WITH_CHUNKED_SUPPORT
RAW_REQUEST = [ RAW_REQUEST = [

View File

@ -3,8 +3,8 @@
Various unicode handling related tests. Various unicode handling related tests.
""" """
from utils import http, HTTP_OK from .utils import http, HTTP_OK
from fixtures import UNICODE from .fixtures import UNICODE
def test_unicode_headers(httpbin): def test_unicode_headers(httpbin):

View File

@ -5,11 +5,11 @@ import pytest
from httpie.cli.exceptions import ParseError from httpie.cli.exceptions import ParseError
from httpie.client import FORM_CONTENT_TYPE from httpie.client import FORM_CONTENT_TYPE
from httpie.status import ExitStatus from httpie.status import ExitStatus
from utils import ( from .utils import (
HTTPBIN_WITH_CHUNKED_SUPPORT, MockEnvironment, StdinBytesIO, http, HTTPBIN_WITH_CHUNKED_SUPPORT, MockEnvironment, StdinBytesIO, http,
HTTP_OK, HTTP_OK,
) )
from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT from .fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
def test_chunked_json(): def test_chunked_json():

View File

@ -4,7 +4,7 @@ import tempfile
import pytest import pytest
from httpie.context import Environment from httpie.context import Environment
from utils import MockEnvironment, http from .utils import MockEnvironment, http
from httpie.compat import is_windows from httpie.compat import is_windows

View File

@ -2,7 +2,7 @@ from typing import Iterable
import pytest import pytest
from tests.utils.matching.parsing import OutputMatchingError, expect_tokens, Expect from .parsing import OutputMatchingError, expect_tokens, Expect
__all__ = [ __all__ = [

View File

@ -3,7 +3,7 @@ from typing import Iterable
from enum import Enum, auto from enum import Enum, auto
from httpie.output.writer import MESSAGE_SEPARATOR from httpie.output.writer import MESSAGE_SEPARATOR
from tests.utils import CRLF from ...utils import CRLF
class Expect(Enum): class Expect(Enum):

View File

@ -3,8 +3,8 @@ Here we test our output parsing and matching implementation, not HTTPie itself.
""" """
from httpie.output.writer import MESSAGE_SEPARATOR from httpie.output.writer import MESSAGE_SEPARATOR
from tests.utils import CRLF from ...utils import CRLF
from tests.utils.matching import assert_output_does_not_match, assert_output_matches, Expect from . import assert_output_does_not_match, assert_output_matches, Expect
def test_assert_output_matches_headers_incomplete(): def test_assert_output_matches_headers_incomplete():