diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:16:54 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:16:54 (GMT) |
commit | fd5d1b51d64280d938b7cdc9d78c632b21b45dff (patch) | |
tree | ed03295de002c168f3ba7aa4b58451b256ba8fba /Lib/test/test_asynchat.py | |
parent | d9e810a8701b92371232eece5896a799c33de505 (diff) | |
download | cpython-fd5d1b51d64280d938b7cdc9d78c632b21b45dff.zip cpython-fd5d1b51d64280d938b7cdc9d78c632b21b45dff.tar.gz cpython-fd5d1b51d64280d938b7cdc9d78c632b21b45dff.tar.bz2 |
asynchat: PEP8-ify the code
Diffstat (limited to 'Lib/test/test_asynchat.py')
-rw-r--r-- | Lib/test/test_asynchat.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index fd50c03..3471739 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -5,9 +5,12 @@ from test import support # If this fails, the test will be skipped. thread = support.import_module('_thread') -import asyncore, asynchat, socket, time -import unittest +import asynchat +import asyncore +import socket import sys +import time +import unittest try: import threading except ImportError: @@ -28,8 +31,8 @@ if threading: self.event = event self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.sock) - # This will be set if the client wants us to wait before echoing data - # back. + # This will be set if the client wants us to wait before echoing + # data back. self.start_resend_event = None def run(self): @@ -52,8 +55,8 @@ if threading: # re-send entire set of collected data try: - # this may fail on some tests, such as test_close_when_done, since - # the client closes the channel when it's done sending + # this may fail on some tests, such as test_close_when_done, + # since the client closes the channel when it's done sending while self.buffer: n = conn.send(self.buffer[:self.chunk_size]) time.sleep(0.001) @@ -96,7 +99,7 @@ if threading: s.start() event.wait() event.clear() - time.sleep(0.01) # Give server time to start accepting. + time.sleep(0.01) # Give server time to start accepting. return s, event @@ -104,10 +107,10 @@ if threading: class TestAsynchat(unittest.TestCase): usepoll = False - def setUp (self): + def setUp(self): self._threads = support.threading_setup() - def tearDown (self): + def tearDown(self): support.threading_cleanup(*self._threads) def line_terminator_check(self, term, server_chunk): @@ -117,7 +120,7 @@ class TestAsynchat(unittest.TestCase): s.start() event.wait() event.clear() - time.sleep(0.01) # Give server time to start accepting. + time.sleep(0.01) # Give server time to start accepting. c = echo_client(term, s.port) c.push(b"hello ") c.push(b"world" + term) @@ -136,17 +139,17 @@ class TestAsynchat(unittest.TestCase): def test_line_terminator1(self): # test one-character terminator - for l in (1,2,3): + for l in (1, 2, 3): self.line_terminator_check(b'\n', l) def test_line_terminator2(self): # test two-character terminator - for l in (1,2,3): + for l in (1, 2, 3): self.line_terminator_check(b'\r\n', l) def test_line_terminator3(self): # test three-character terminator - for l in (1,2,3): + for l in (1, 2, 3): self.line_terminator_check(b'qqq', l) def numeric_terminator_check(self, termlen): @@ -269,11 +272,13 @@ class TestAsynchat(unittest.TestCase): class TestAsynchat_WithPoll(TestAsynchat): usepoll = True + class TestHelperFunctions(unittest.TestCase): def test_find_prefix_at_end(self): self.assertEqual(asynchat.find_prefix_at_end("qwerty\r", "\r\n"), 1) self.assertEqual(asynchat.find_prefix_at_end("qwertydkjf", "\r\n"), 0) + class TestFifo(unittest.TestCase): def test_basic(self): f = asynchat.fifo() |