1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

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
50 changed files with 118 additions and 118 deletions

0
tests/__init__.py Normal file
View File

View File

@@ -5,7 +5,7 @@ import pytest
from httpie.plugins.builtin import HTTPBasicAuth
from httpie.status import ExitStatus
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.definition

View File

@@ -3,7 +3,7 @@ from unittest import mock
from httpie.cli.constants import SEPARATOR_CREDENTIALS
from httpie.plugins import AuthPlugin
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

View File

@@ -1,9 +1,9 @@
"""Tests for dealing with binary request and response data."""
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 utils import MockEnvironment, http
from .utils import MockEnvironment, http
class TestBinaryRequestData:

View File

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

View File

@@ -11,9 +11,9 @@ our zlib-encoded request data.
import base64
import zlib
from fixtures import FILE_PATH, FILE_CONTENT
from .fixtures import FILE_PATH, FILE_CONTENT
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):

View File

@@ -9,7 +9,7 @@ from httpie.config import (
DEFAULT_RELATIVE_XDG_CONFIG_HOME, DEFAULT_WINDOWS_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):

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
from unittest import mock
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):

View File

@@ -6,11 +6,11 @@ import pytest
import httpie
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.context import Environment
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():

View File

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

View File

@@ -19,7 +19,7 @@ from httpie.cli.argtypes import (
from httpie.cli.definition import parser
from httpie.output.formatters.colors import get_lexer
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])

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,11 +5,11 @@ import pytest
from httpie.cli.exceptions import ParseError
from httpie.client import FORM_CONTENT_TYPE
from httpie.status import ExitStatus
from utils import (
from .utils import (
HTTPBIN_WITH_CHUNKED_SUPPORT, MockEnvironment, StdinBytesIO, http,
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():

View File

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

View File

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

View File

@@ -3,7 +3,7 @@ from typing import Iterable
from enum import Enum, auto
from httpie.output.writer import MESSAGE_SEPARATOR
from tests.utils import CRLF
from ...utils import CRLF
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 tests.utils import CRLF
from tests.utils.matching import assert_output_does_not_match, assert_output_matches, Expect
from ...utils import CRLF
from . import assert_output_does_not_match, assert_output_matches, Expect
def test_assert_output_matches_headers_incomplete():