style: use .format() instead of % formatting
diff --git a/test/test.py b/test/test.py
index 8b38c8c..db03907 100644
--- a/test/test.py
+++ b/test/test.py
@@ -66,7 +66,7 @@
self.s.write(block)
# there might be a small delay until the character is ready (especially on win32)
time.sleep(0.05)
- self.assertEqual(self.s.in_waiting, length, "expected exactly %d character for inWainting()" % length)
+ self.assertEqual(self.s.in_waiting, length, "expected exactly {} character for inWainting()".format(length))
self.assertEqual(self.s.read(length), block) #, "expected a %r which was written before" % block)
self.assertEqual(self.s.read(1), b'', "expected empty buffer after all sent chars are read")
@@ -131,7 +131,7 @@
a character is sent after some time to terminate the test (SendEvent)."""
c = self.s.read(1)
if not (self.event.isSet() and c == b'E'):
- self.fail("expected marker (evt=%r, c=%r)" % (self.event.isSet(), c))
+ self.fail("expected marker (evt={!r}, c={!r})".format(self.event.isSet(), c))
class Test2_Forever(unittest.TestCase):
@@ -220,14 +220,14 @@
t1 = time.time()
self.assertRaises(serial.SerialTimeoutException, self.s.write, b"timeout please" * 200)
t2 = time.time()
- self.assertTrue(0.9 <= (t2 - t1) < 2.1, "Timeout not in the given interval (%s)" % (t2 - t1))
+ self.assertTrue(0.9 <= (t2 - t1) < 2.1, "Timeout not in the given interval ({})".format(t2 - t1))
if __name__ == '__main__':
sys.stdout.write(__doc__)
if len(sys.argv) > 1:
PORT = sys.argv[1]
- sys.stdout.write("Testing port: %r\n" % PORT)
+ sys.stdout.write("Testing port: {!r}\n".format(PORT))
sys.argv[1:] = ['-v']
# When this module is executed from the command-line, it runs all its tests
unittest.main()