this makes checking for warnings less error prone
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 16c2b9e..816cedb 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -317,9 +317,8 @@
                                   randrange)
                 with check_warnings(("integer argument expected, "
                                      "got non-integer", DeprecationWarning)):
-                    self.assertRaises((TypeError, struct.error),
-                                      struct.pack, self.format,
-                                      3+42j)
+                    with self.assertRaises((TypeError, struct.error)):
+                        struct.pack(self.format, 3+42j)
 
                 # an attempt to convert a non-integer (with an
                 # implicit conversion via __int__) should succeed,