Permalink
Browse files

Cleanup

  • Loading branch information...
jakubroztocil committed Aug 17, 2013
1 parent 6749616 commit 00de49f4c377620273219f0bb2e30f3eaab7a0ed
Showing with 12 additions and 7 deletions.
  1. +2 −1 httpie/compat.py
  2. +2 −2 httpie/downloads.py
  3. +1 −0 httpie/models.py
  4. +7 −4 tests/tests.py
View
@@ -12,7 +12,8 @@
)
try:
+ #noinspection PyUnresolvedReferences,PyCompatibility
from urllib.parse import urlsplit
except ImportError:
+ #noinspection PyUnresolvedReferences,PyCompatibility
from urlparse import urlsplit
-
View
@@ -241,7 +241,7 @@ def start(self, response):
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 @@ def interrupted(self):
and self.status.total_size != self.status.downloaded
)
- def _chunk_downloaded(self, chunk):
+ def chunk_downloaded(self, chunk):
"""
A download progress callback.
View
@@ -109,6 +109,7 @@ def iter_body(self, chunk_size=1):
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
View
@@ -23,6 +23,7 @@
import os
import sys
import json
+#noinspection PyCompatibility
import argparse
import tempfile
import unittest
@@ -31,9 +32,11 @@
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,17 +1616,17 @@ def test_download_with_Content_Length(self):
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)
def test_download_no_Content_Length(self):
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 @@ def test_download_interrupted(self):
url=httpbin('/'),
headers={'Content-Length': 5}
))
- download._chunk_downloaded(b'1234')
+ download.chunk_downloaded(b'1234')
download.finish()
self.assertTrue(download.interrupted)

0 comments on commit 00de49f

Please sign in to comment.