From 00de49f4c377620273219f0bb2e30f3eaab7a0ed Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Sun, 18 Aug 2013 00:59:10 +0200 Subject: [PATCH] Cleanup --- httpie/compat.py | 3 ++- httpie/downloads.py | 4 ++-- httpie/models.py | 1 + tests/tests.py | 11 +++++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/httpie/compat.py b/httpie/compat.py index 0310e233..2a46528b 100644 --- a/httpie/compat.py +++ b/httpie/compat.py @@ -12,7 +12,8 @@ from requests.compat import ( ) try: + #noinspection PyUnresolvedReferences,PyCompatibility from urllib.parse import urlsplit except ImportError: + #noinspection PyUnresolvedReferences,PyCompatibility from urlparse import urlsplit - diff --git a/httpie/downloads.py b/httpie/downloads.py index 7e75f214..5c16cb2a 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -241,7 +241,7 @@ class Download(object): msg=HTTPResponse(response), with_headers=False, with_body=True, - on_body_chunk_downloaded=self._chunk_downloaded, + on_body_chunk_downloaded=self.chunk_downloaded, chunk_size=1024 * 8 ) @@ -273,7 +273,7 @@ class Download(object): and self.status.total_size != self.status.downloaded ) - def _chunk_downloaded(self, chunk): + def chunk_downloaded(self, chunk): """ A download progress callback. diff --git a/httpie/models.py b/httpie/models.py index 4bedad33..41c4d73a 100644 --- a/httpie/models.py +++ b/httpie/models.py @@ -109,6 +109,7 @@ class HTTPResponse(HTTPMessage): def iter_lines(self, chunk_size): return ((line, b'\n') for line in self._orig.iter_lines(chunk_size)) + #noinspection PyProtectedMember @property def headers(self): original = self._orig.raw._original_response diff --git a/tests/tests.py b/tests/tests.py index 7fdbf185..34dc2042 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -23,6 +23,7 @@ import subprocess import os import sys import json +#noinspection PyCompatibility import argparse import tempfile import unittest @@ -31,9 +32,11 @@ import time from requests.structures import CaseInsensitiveDict try: + #noinspection PyCompatibility from urllib.request import urlopen except ImportError: # noinspection PyUnresolvedReferences + #noinspection PyCompatibility from urllib2 import urlopen try: from unittest import skipIf, skip @@ -1613,9 +1616,9 @@ class DownloadTest(BaseTestCase): headers={'Content-Length': 10} )) time.sleep(1.1) - download._chunk_downloaded(b'12345') + download.chunk_downloaded(b'12345') time.sleep(1.1) - download._chunk_downloaded(b'12345') + download.chunk_downloaded(b'12345') download.finish() self.assertFalse(download.interrupted) @@ -1623,7 +1626,7 @@ class DownloadTest(BaseTestCase): download = Download(output_file=open(os.devnull, 'w')) download.start(Response(url=httpbin('/'))) time.sleep(1.1) - download._chunk_downloaded(b'12345') + download.chunk_downloaded(b'12345') download.finish() self.assertFalse(download.interrupted) @@ -1633,7 +1636,7 @@ class DownloadTest(BaseTestCase): url=httpbin('/'), headers={'Content-Length': 5} )) - download._chunk_downloaded(b'1234') + download.chunk_downloaded(b'1234') download.finish() self.assertTrue(download.interrupted)