From f6a19cf55264a9fa1c5c32f11a2ac945cb9bb641 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Wed, 8 Mar 2017 09:49:51 +0100 Subject: [PATCH] Don't call external URLs from tests #729 --- CHANGELOG.rst | 6 ++++++ httpie/__init__.py | 2 +- tests/test_binary.py | 27 +++++++++++---------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2dc482c78c..f889302566 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,12 @@ This document records all notable changes to `HTTPie `_. This project adheres to `Semantic Versioning `_. +`1.0.1`_ (2018-11-14) +------------------------- + +* Removed external URL calls from tests. + + `1.0.0`_ (2018-11-02) ------------------------- diff --git a/httpie/__init__.py b/httpie/__init__.py index 36bb65955d..90dc63beff 100644 --- a/httpie/__init__.py +++ b/httpie/__init__.py @@ -2,7 +2,7 @@ HTTPie - a CLI, cURL-like tool for humans. """ -__version__ = '1.0.0' +__version__ = '1.0.1' __author__ = 'Jakub Roztocil' __licence__ = 'BSD' diff --git a/tests/test_binary.py b/tests/test_binary.py index cb6da2e85d..2adc2500be 100644 --- a/tests/test_binary.py +++ b/tests/test_binary.py @@ -1,6 +1,7 @@ """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 httpie.compat import urlopen from httpie.output.streams import BINARY_SUPPRESSED_NOTICE from utils import MockEnvironment, http @@ -31,25 +32,19 @@ def test_binary_file_form(self, httpbin): class TestBinaryResponseData: - url = 'http://www.google.com/favicon.ico' - - @property - def bindata(self): - 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) + def test_binary_suppresses_when_terminal(self, httpbin): + r = http('GET', httpbin + '/bytes/1024') 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) - r = http('--pretty=all', 'GET', self.url, - env=env) + r = http('--pretty=all', 'GET', httpbin + '/bytes/1024', env=env) 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) - r = http('GET', self.url, env=env) - assert r == self.bindata + url = httpbin + '/bytes/1024?seed=1' + r = http('GET', url, env=env) + expected = requests.get(url).content + assert r == expected