diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2011-02-09 19:09:40 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2011-02-09 19:09:40 +0000 |
commit | 84cc72b5c4e336e2fadd767f3de62194dd0ceebb (patch) | |
tree | d9f32183956730f54ace0814274c92d47ed46f9a /test | |
parent | 149ae9a0dfd847eeb8f0856b8e7d7461c9665725 (diff) | |
download | pysendfile-84cc72b5c4e336e2fadd767f3de62194dd0ceebb.tar.gz |
return just the number of bytes sent instead of a (bsent, offset) tuple.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_sendfile.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/test/test_sendfile.py b/test/test_sendfile.py index 7c37cd1..5385f54 100644 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -122,10 +122,10 @@ def sendfile_wrapper(sock, file, offset, nbytes, headers=[], trailers=[]): while 1: try: if SUPPORT_HEADERS_TRAILERS: - sent, new_offset = sendfile.sendfile(sock, file, offset, nbytes, + return sendfile.sendfile(sock, file, offset, nbytes, headers, trailers) else: - sent, new_offset = sendfile.sendfile(sock, file, offset, nbytes) + return sendfile.sendfile(sock, file, offset, nbytes) except OSError as err: if err.errno == errno.ECONNRESET: # disconnected @@ -135,9 +135,6 @@ def sendfile_wrapper(sock, file, offset, nbytes, headers=[], trailers=[]): continue else: raise - else: - assert (new_offset - offset) <= sent - return (sent, new_offset) class TestSendfile(unittest.TestCase): @@ -166,10 +163,11 @@ class TestSendfile(unittest.TestCase): offset = 0 nbytes = 4096 while 1: - sent, offset = sendfile_wrapper(self.sockno, self.fileno, offset, nbytes) + sent = sendfile_wrapper(self.sockno, self.fileno, offset, nbytes) if sent == 0: break total_sent += sent + offset += sent self.assertTrue(sent <= nbytes) self.assertEqual(offset, total_sent) @@ -185,10 +183,11 @@ class TestSendfile(unittest.TestCase): offset = int(len(DATA) / 2) nbytes = 4096 while 1: - sent, offset = sendfile_wrapper(self.sockno, self.fileno, offset, nbytes) + sent = sendfile_wrapper(self.sockno, self.fileno, offset, nbytes) if sent == 0: break total_sent += sent + offset += sent self.assertTrue(sent <= nbytes) self.client.close() @@ -201,7 +200,7 @@ class TestSendfile(unittest.TestCase): def test_offset_overflow(self): # specify an offset > file size offset = len(DATA) + 4096 - sent, new_offset = sendfile.sendfile(self.sockno, self.fileno, offset, 4096) + sent = sendfile.sendfile(self.sockno, self.fileno, offset, 4096) self.assertEqual(sent, 0) self.client.close() self.server.wait() |