diff options
author | Chris Liechti <cliechti@gmx.net> | 2016-05-26 17:14:58 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2016-05-26 17:14:58 +0200 |
commit | 77d922b37478443135c495e37c9c784711d54a87 (patch) | |
tree | 8b020bfd11dabc260453861a6e86b83073d07557 | |
parent | 3401840263f36691495ddb749def54e6fbd9ddf4 (diff) | |
download | pyserial-git-77d922b37478443135c495e37c9c784711d54a87.tar.gz |
style: flake8 findings
-rw-r--r-- | serial/serialwin32.py | 3 | ||||
-rw-r--r-- | test/run_all_tests.py | 4 | ||||
-rw-r--r-- | test/test_cancel.py | 11 |
3 files changed, 8 insertions, 10 deletions
diff --git a/serial/serialwin32.py b/serial/serialwin32.py index 9cb2620..037f282 100644 --- a/serial/serialwin32.py +++ b/serial/serialwin32.py @@ -314,7 +314,7 @@ class Serial(SerialBase): #~ win32.WaitForSingleObject(self._overlapped_write.hEvent, win32.INFINITE) err = win32.GetOverlappedResult(self._port_handle, self._overlapped_write, ctypes.byref(n), True) if win32.GetLastError() == win32.ERROR_OPERATION_ABORTED: - return n.value # canceled IO is no error + return n.value # canceled IO is no error if n.value != len(data): raise writeTimeoutError return n.value @@ -451,4 +451,3 @@ class Serial(SerialBase): def cancel_write(self): """Cancel a blocking write operation, may be called from other thread""" self._cancel_overlapped_io(self._overlapped_write) - diff --git a/test/run_all_tests.py b/test/run_all_tests.py index 6836d59..355cd44 100644 --- a/test/run_all_tests.py +++ b/test/run_all_tests.py @@ -14,10 +14,10 @@ import unittest import sys import os -# inject local copy to avoid testing the installed version instead of the +# inject local copy to avoid testing the installed version instead of the one in the repo sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) -import serial +import serial # noqa print("Patching sys.path to test local version. Testing Version: %s" % (serial.VERSION,)) PORT = 'loop://' diff --git a/test/test_cancel.py b/test/test_cancel.py index e1a0634..210891b 100644 --- a/test/test_cancel.py +++ b/test/test_cancel.py @@ -7,8 +7,6 @@ """ Test cancel functionality. """ - -import os import sys import unittest import threading @@ -18,6 +16,7 @@ import serial # on which port should the tests be performed: PORT = 'loop://' + @unittest.skipIf(not hasattr(serial.Serial, 'cancel_read'), "cancel_read not supported on platform") class TestCancelRead(unittest.TestCase): """Test cancel_read functionality""" @@ -46,7 +45,7 @@ class TestCancelRead(unittest.TestCase): self.s.read(1000) t2 = time.time() self.assertEqual(self.cancel_called, 1) - self.assertTrue(0.5 < (t2 - t1) < 2, 'Function did not return in time: {}'.format(t2-t1)) + self.assertTrue(0.5 < (t2 - t1) < 2, 'Function did not return in time: {}'.format(t2 - t1)) #~ self.assertTrue(not self.s.isOpen()) #~ self.assertRaises(serial.SerialException, self.s.open) @@ -55,7 +54,8 @@ class TestCancelRead(unittest.TestCase): #~ self.s.read() -DATA = b'#'*1024 +DATA = b'#' * 1024 + @unittest.skipIf(not hasattr(serial.Serial, 'cancel_write'), "cancel_read not supported on platform") class TestCancelWrite(unittest.TestCase): @@ -89,7 +89,7 @@ class TestCancelWrite(unittest.TestCase): self.s.write(DATA) t2 = time.time() self.assertEqual(self.cancel_called, 1) - self.assertTrue(0.5 < (t2 - t1) < 2, 'Function did not return in time: {}'.format(t2-t1)) + self.assertTrue(0.5 < (t2 - t1) < 2, 'Function did not return in time: {}'.format(t2 - t1)) #~ self.assertTrue(not self.s.isOpen()) #~ self.assertRaises(serial.SerialException, self.s.open) @@ -100,7 +100,6 @@ class TestCancelWrite(unittest.TestCase): if __name__ == '__main__': - import sys sys.stdout.write(__doc__) if len(sys.argv) > 1: PORT = sys.argv[1] |