Skip to content

Commit

Permalink
Merge branch 'master' into migrate-to-pyproject-toml
Browse files Browse the repository at this point in the history
  • Loading branch information
deronnax committed Mar 4, 2024
2 parents 034eb08 + 3de7c82 commit 1b60638
Show file tree
Hide file tree
Showing 26 changed files with 229 additions and 227 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version:
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.7'
pyopenssl: [0, 1]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Custom [HTTP method](https://httpie.io/docs#http-method), [HTTP headers](https:/
http PUT pie.dev/put X-API-Token:123 name=John
```

Build and print a request without sending it using [offline mode](https://httpie.io/docs#offline-mode):
Build and print a request without sending it using [offline mode](https://httpie.io/docs/cli/offline-mode):

```bash
http --offline pie.dev/post hello=offline
Expand Down
12 changes: 6 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Also works for other Debian-derived distributions like MX Linux, Linux Mint, dee
```bash
# Install httpie
$ curl -SsL https://packages.httpie.io/deb/KEY.gpg | sudo gpg --dearmor -o /usr/share/keyrings/httpie.gpg
$ sudo echo "deb [arch=amd64 signed-by=/usr/share/keyrings/httpie.gpg] https://packages.httpie.io/deb ./" > /etc/apt/sources.list.d/httpie.list
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/httpie.gpg] https://packages.httpie.io/deb ./" | sudo tee /etc/apt/sources.list.d/httpie.list > /dev/null
$ sudo apt update
$ sudo apt install httpie
```
Expand Down Expand Up @@ -477,7 +477,7 @@ $ http pie.dev/get text==@files/text.txt
### URL shortcuts for `localhost`
Additionally, curl-like shorthand for localhost is supported.
This means that, for example, `:3000` would expand to `http://localhost:3000`
This means that, for example, `:3000` would expand to `http://localhost:3000`.
If the port is omitted, then port 80 is assumed.
```bash
Expand Down Expand Up @@ -530,7 +530,7 @@ $ http-unix %2Fvar%2Frun%2Fdocker.sock/info
### `--path-as-is`
The standard behavior of HTTP clients is to normalize the path portion of URLs by squashing dot segments as a typically filesystem would:
The standard behavior of HTTP clients is to normalize the path portion of URLs by squashing dot segments as a typical filesystem would:
```bash
$ http -v example.org/./../../etc/password
Expand Down Expand Up @@ -583,7 +583,7 @@ Note that the structured data fields aren’t the only way to specify request da
### File based separators
Using file contents as values for specific fields is a very common use case, which can be achieved through adding the `@` suffix to
the operators above. For example instead of using a static string as the value for some header, you can use `:@` operator
the operators above. For example, instead of using a static string as the value for some header, you can use `:@` operator
to pass the desired value from a file.
```bash
Expand Down Expand Up @@ -749,7 +749,7 @@ $ http --offline --print=B pie.dev/post \
In the example above, the `search[type]` is an instruction for creating an object called `search`, and setting the `type` field of it to the given value (`"id"`).
Also note that, just as the regular syntax, you can use the `:=` operator to directly pass raw JSON values (e.g, numbers in the case above).
Also note that, just as the regular syntax, you can use the `:=` operator to directly pass raw JSON values (e.g., numbers in the case above).
```json
{
Expand Down Expand Up @@ -1235,7 +1235,7 @@ by individual commands when sending a request instead of being joined together.
### Limiting response headers
The `--max-headers=n` options allows you to control the number of headers HTTPie reads before giving up (the default `0`, i.e., there’s no limit).
The `--max-headers=n` option allows you to control the number of headers HTTPie reads before giving up (the default `0`, i.e., there’s no limit).
```bash
$ http --max-headers=100 pie.dev/get
Expand Down
2 changes: 1 addition & 1 deletion docs/installation/methods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tools:
install:
- curl -SsL https://packages.httpie.io/deb/KEY.gpg | sudo gpg --dearmor -o /usr/share/keyrings/httpie.gpg
# - curl -SsL -o /etc/apt/sources.list.d/httpie.list https://packages.httpie.io/deb/httpie.list
- sudo echo "deb [arch=amd64 signed-by=/usr/share/keyrings/httpie.gpg] https://packages.httpie.io/deb ./" > /etc/apt/sources.list.d/httpie.list
- echo "deb [arch=amd64 signed-by=/usr/share/keyrings/httpie.gpg] https://packages.httpie.io/deb ./" | sudo tee /etc/apt/sources.list.d/httpie.list > /dev/null
- sudo apt update
- sudo apt install httpie
upgrade:
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ console_scripts =
dev =
pytest
pytest-httpbin>=0.0.6
pytest-lazy-fixture>=0.0.6
responses
pytest-mock
werkzeug<2.1.0
Expand Down
5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

11 changes: 8 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

import pytest
from pytest_httpbin import certs
from pytest_httpbin.serve import Server as PyTestHttpBinServer

from .utils import ( # noqa
from .utils import ( # noqa
HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN,
HTTPBIN_WITH_CHUNKED_SUPPORT,
REMOTE_HTTPBIN_DOMAIN,
IS_PYOPENSSL,
mock_env
)
from .utils.plugins_cli import ( # noqa
from .utils.plugins_cli import ( # noqa
broken_plugin,
dummy_plugin,
dummy_plugins,
httpie_plugins,
httpie_plugins_success,
interface,
)
from .utils.http_server import http_server, localhost_http_server # noqa
from .utils.http_server import http_server, localhost_http_server # noqa


# Patch to support `url = str(server)` in addition to `url = server + '/foo'`.
PyTestHttpBinServer.__str__ = lambda self: self.url


@pytest.fixture(scope='function', autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_bearer_auth(httpbin_both, token):
new=lambda self, prompt: 'password')
def test_password_prompt(httpbin):
r = http('--auth', 'user',
'GET', httpbin.url + '/basic-auth/user/password')
'GET', httpbin + '/basic-auth/user/password')
assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'}

Expand Down
6 changes: 3 additions & 3 deletions tests/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ def test_binary_stdin(self, httpbin):
stdin_isatty=False,
stdout_isatty=False
)
r = http('--print=B', 'POST', httpbin.url + '/post', env=env)
r = http('--print=B', 'POST', httpbin + '/post', env=env)
assert r == BIN_FILE_CONTENT

def test_binary_file_path(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
r = http('--print=B', 'POST', httpbin.url + '/post',
r = http('--print=B', 'POST', httpbin + '/post',
'@' + BIN_FILE_PATH_ARG, env=env)
assert r == BIN_FILE_CONTENT

def test_binary_file_form(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
r = http('--print=B', '--form', 'POST', httpbin.url + '/post',
r = http('--print=B', '--form', 'POST', httpbin + '/post',
'test@' + BIN_FILE_PATH_ARG, env=env)
assert bytes(BIN_FILE_CONTENT) in bytes(r)

Expand Down
20 changes: 10 additions & 10 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,27 @@ def test_multiple_text_fields_with_same_field_name(self):

class TestQuerystring:
def test_query_string_params_in_url(self, httpbin):
r = http('--print=Hhb', 'GET', httpbin.url + '/get?a=1&b=2')
r = http('--print=Hhb', 'GET', httpbin + '/get?a=1&b=2')
path = '/get?a=1&b=2'
url = httpbin.url + path
url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r

def test_query_string_params_items(self, httpbin):
r = http('--print=Hhb', 'GET', httpbin.url + '/get', 'a==1')
r = http('--print=Hhb', 'GET', httpbin + '/get', 'a==1')
path = '/get?a=1'
url = httpbin.url + path
url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r

def test_query_string_params_in_url_and_items_with_duplicates(self,
httpbin):
r = http('--print=Hhb', 'GET',
httpbin.url + '/get?a=1&a=1', 'a==1', 'a==1')
httpbin + '/get?a=1&a=1', 'a==1', 'a==1')
path = '/get?a=1&a=1&a=1&a=1'
url = httpbin.url + path
url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r
Expand Down Expand Up @@ -320,11 +320,11 @@ def test_guess_when_method_set_but_invalid_and_item_exists(self):
class TestNoOptions:

def test_valid_no_options(self, httpbin):
r = http('--verbose', '--no-verbose', 'GET', httpbin.url + '/get')
r = http('--verbose', '--no-verbose', 'GET', httpbin + '/get')
assert 'GET /get HTTP/1.1' not in r

def test_invalid_no_options(self, httpbin):
r = http('--no-war', 'GET', httpbin.url + '/get',
r = http('--no-war', 'GET', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'unrecognized arguments: --no-war' in r.stderr
Expand All @@ -338,13 +338,13 @@ def test_ignore_stdin(self, httpbin):
stdin=StdinBytesIO(FILE_PATH.read_bytes()),
stdin_isatty=False,
)
r = http('--ignore-stdin', '--verbose', httpbin.url + '/get', env=env)
r = http('--ignore-stdin', '--verbose', httpbin + '/get', env=env)
assert HTTP_OK in r
assert 'GET /get HTTP' in r, "Don't default to POST."
assert FILE_CONTENT not in r, "Don't send stdin data."

def test_ignore_stdin_cannot_prompt_password(self, httpbin):
r = http('--ignore-stdin', '--auth=no-password', httpbin.url + '/get',
r = http('--ignore-stdin', '--auth=no-password', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'because --ignore-stdin' in r.stderr
Expand Down
4 changes: 2 additions & 2 deletions tests/test_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def assert_decompressed_equal(base64_compressed_data, expected_str):


def test_cannot_combine_compress_with_chunked(httpbin):
r = http('--compress', '--chunked', httpbin.url + '/get',
r = http('--compress', '--chunked', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'cannot combine --compress and --chunked' in r.stderr


def test_cannot_combine_compress_with_multipart(httpbin):
r = http('--compress', '--multipart', httpbin.url + '/get',
r = http('--compress', '--multipart', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'cannot combine --compress and --multipart' in r.stderr
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_default_options(httpbin):
env = MockEnvironment()
env.config['default_options'] = ['--form']
env.config.save()
r = http(httpbin.url + '/post', 'foo=bar', env=env)
r = http(httpbin + '/post', 'foo=bar', env=env)
assert r.json['form'] == {
"foo": "bar"
}
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_default_options_overwrite(httpbin):
env = MockEnvironment()
env.config['default_options'] = ['--form']
env.config.save()
r = http('--json', httpbin.url + '/post', 'foo=bar', env=env)
r = http('--json', httpbin + '/post', 'foo=bar', env=env)
assert r.json['json'] == {
"foo": "bar"
}
Expand Down
Loading

0 comments on commit 1b60638

Please sign in to comment.