summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2008-07-13 12:25:08 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2008-07-13 12:25:08 (GMT)
commitb130493834e5bd807ab80dcd8b417d7623baca24 (patch)
tree3842a93fe70989950ba9db64bc8d4a5543286e59 /Lib/test/test_struct.py
parent628b1b3659d9db96210cb599579b79625eed1488 (diff)
downloadcpython-b130493834e5bd807ab80dcd8b417d7623baca24.zip
cpython-b130493834e5bd807ab80dcd8b417d7623baca24.tar.gz
cpython-b130493834e5bd807ab80dcd8b417d7623baca24.tar.bz2
Make test.test_support.catch_warnings more robust as discussed on python-dev. Also add explicit tests for it to test_warnings. (forward port of r64910 from trunk)
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index bce8fdc..6dc0e8d 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -35,12 +35,9 @@ def with_warning_restore(func):
@wraps(func)
def decorator(*args, **kw):
with catch_warning():
- # Grrr, we need this function to warn every time. Without removing
- # the warningregistry, running test_tarfile then test_struct would fail
- # on 64-bit platforms.
- globals = func.__globals__
- if '__warningregistry__' in globals:
- del globals['__warningregistry__']
+ # We need this function to warn every time, so stick an
+ # unqualifed 'always' at the head of the filter list
+ warnings.simplefilter("always")
warnings.filterwarnings("error", category=DeprecationWarning)
return func(*args, **kw)
return decorator
@@ -53,7 +50,7 @@ def deprecated_err(func, *args):
pass
except DeprecationWarning:
if not PY_STRUCT_OVERFLOW_MASKING:
- raise TestFailed("%s%s expected to raise struct.error" % (
+ raise TestFailed("%s%s expected to raise DeprecationWarning" % (
func.__name__, args))
else:
raise TestFailed("%s%s did not raise error" % (