]> granicus.if.org Git - python/commitdiff
Issue #29300: test_struct tests unpack_from() with keywords
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 2 Feb 2017 13:18:18 +0000 (14:18 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 2 Feb 2017 13:18:18 +0000 (14:18 +0100)
Add an unit test on the _struct.Struct.unpack_from() method to test passing
arguments as keywords.

Lib/test/test_struct.py

index efbdbfcc584bb08cac322b9eefdd65cf2813f110..9b8178f84abbb48779d8c27cbd83a062a5260b9d 100644 (file)
@@ -428,6 +428,10 @@ class StructTest(unittest.TestCase):
             for i in range(6, len(test_string) + 1):
                 self.assertRaises(struct.error, struct.unpack_from, fmt, data, i)
 
+        # keyword arguments
+        self.assertEqual(s.unpack_from(buffer=test_string, offset=2),
+                         (b'cd01',))
+
     def test_pack_into(self):
         test_string = b'Reykjavik rocks, eow!'
         writable_buf = array.array('b', b' '*100)