diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:19:33 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:19:33 (GMT) |
commit | 7b9328f51bee311ff943af660f3b5f1b35d4e196 (patch) | |
tree | 666d244e5a5046c1c9dbd6ab0d9bcca9e7e4429d /Lib/test | |
parent | e8209dab6b28638bc5b7afd361f797ab302ac898 (diff) | |
parent | fd5d1b51d64280d938b7cdc9d78c632b21b45dff (diff) | |
download | cpython-7b9328f51bee311ff943af660f3b5f1b35d4e196.zip cpython-7b9328f51bee311ff943af660f3b5f1b35d4e196.tar.gz cpython-7b9328f51bee311ff943af660f3b5f1b35d4e196.tar.bz2 |
(Merge 3.4) asynchat: PEP8-ify the code
Diffstat (limited to 'Lib/test')
-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 23944d7..f6b17f9 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 import warnings try: import threading @@ -29,8 +32,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): @@ -53,8 +56,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) @@ -97,7 +100,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 @@ -105,10 +108,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): @@ -118,7 +121,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) @@ -137,17 +140,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): @@ -270,11 +273,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): with warnings.catch_warnings(record=True) as w: |