forked from extern/httpie-cli
Don't call external URLs from tests #729
This commit is contained in:
parent
74979f3b33
commit
f6a19cf552
@ -6,6 +6,12 @@ This document records all notable changes to `HTTPie <http://httpie.org>`_.
|
|||||||
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
`1.0.1`_ (2018-11-14)
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
* Removed external URL calls from tests.
|
||||||
|
|
||||||
|
|
||||||
`1.0.0`_ (2018-11-02)
|
`1.0.0`_ (2018-11-02)
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
HTTPie - a CLI, cURL-like tool for humans.
|
HTTPie - a CLI, cURL-like tool for humans.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
__version__ = '1.0.0'
|
__version__ = '1.0.1'
|
||||||
__author__ = 'Jakub Roztocil'
|
__author__ = 'Jakub Roztocil'
|
||||||
__licence__ = 'BSD'
|
__licence__ = 'BSD'
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Tests for dealing with binary request and response data."""
|
"""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.compat import urlopen
|
|
||||||
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
|
||||||
|
|
||||||
@ -31,25 +32,19 @@ class TestBinaryRequestData:
|
|||||||
|
|
||||||
|
|
||||||
class TestBinaryResponseData:
|
class TestBinaryResponseData:
|
||||||
url = 'http://www.google.com/favicon.ico'
|
|
||||||
|
|
||||||
@property
|
def test_binary_suppresses_when_terminal(self, httpbin):
|
||||||
def bindata(self):
|
r = http('GET', httpbin + '/bytes/1024')
|
||||||
if not hasattr(self, '_bindata'):
|
|
||||||
self._bindata = urlopen(self.url).read()
|
|
||||||
return self._bindata
|
|
||||||
|
|
||||||
def test_binary_suppresses_when_terminal(self):
|
|
||||||
r = http('GET', self.url)
|
|
||||||
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
||||||
|
|
||||||
def test_binary_suppresses_when_not_terminal_but_pretty(self):
|
def test_binary_suppresses_when_not_terminal_but_pretty(self, httpbin):
|
||||||
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
|
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||||
r = http('--pretty=all', 'GET', self.url,
|
r = http('--pretty=all', 'GET', httpbin + '/bytes/1024', env=env)
|
||||||
env=env)
|
|
||||||
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
||||||
|
|
||||||
def test_binary_included_and_correct_when_suitable(self):
|
def test_binary_included_and_correct_when_suitable(self, httpbin):
|
||||||
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
|
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||||
r = http('GET', self.url, env=env)
|
url = httpbin + '/bytes/1024?seed=1'
|
||||||
assert r == self.bindata
|
r = http('GET', url, env=env)
|
||||||
|
expected = requests.get(url).content
|
||||||
|
assert r == expected
|
||||||
|
Loading…
Reference in New Issue
Block a user