summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-23 13:11:12 (GMT)
committerGitHub <noreply@github.com>2017-06-23 13:11:12 (GMT)
commitf87b85f80853c580b1c8bf78a51b0e9a25f6e1a7 (patch)
tree8417421b14db403e4df4b264c4e4ec09e7c1f4b9 /Lib/test/test_struct.py
parenta4b091e135ccf345cfafdd8477aef897c5214f82 (diff)
downloadcpython-f87b85f80853c580b1c8bf78a51b0e9a25f6e1a7.zip
cpython-f87b85f80853c580b1c8bf78a51b0e9a25f6e1a7.tar.gz
cpython-f87b85f80853c580b1c8bf78a51b0e9a25f6e1a7.tar.bz2
bpo-21071: struct.Struct.format type is now str (#845)
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index b2a5f42..a896468 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -618,6 +618,14 @@ class StructTest(unittest.TestCase):
# Shouldn't crash.
self.assertEqual(struct.unpack(b'b', b'a'), (b'a'[0],))
+ def test_format_attr(self):
+ s = struct.Struct('=i2H')
+ self.assertEqual(s.format, '=i2H')
+
+ # use a bytes string
+ s2 = struct.Struct(s.format.encode())
+ self.assertEqual(s2.format, s.format)
+
class UnpackIteratorTest(unittest.TestCase):
"""