Commit 43ebe4b6 authored by Tim Peters's avatar Tim Peters

test_cache(): Muck with Python's warnings module.

The test didn't work if run more than once (e.g., via Zope3's
 test.py's "-N <n>" argument, or via ZODB's test.py's "-L"
argument), because the warnings module suppresses warnings
after the first a single line.  Made the warnings module
report repeats of DeprecationWarnings for the duration of
the test.
parent cf0782f0
...@@ -407,6 +407,13 @@ class UserMethodTests(unittest.TestCase): ...@@ -407,6 +407,13 @@ class UserMethodTests(unittest.TestCase):
>>> hook = WarningsHook() >>> hook = WarningsHook()
>>> hook.install() >>> hook.install()
More problems in case this test is run more than once: fool the
warnings module into delivering the warnings despite that they've
been seen before.
>>> import warnings
>>> warnings.filterwarnings("always", category=DeprecationWarning)
>>> r._p_activate() >>> r._p_activate()
>>> cn.cacheMinimize(12) >>> cn.cacheMinimize(12)
>>> r._p_state >>> r._p_state
...@@ -450,6 +457,10 @@ class UserMethodTests(unittest.TestCase): ...@@ -450,6 +457,10 @@ class UserMethodTests(unittest.TestCase):
>>> hook.uninstall() >>> hook.uninstall()
Obscure: There is no API call for removing the filter we added, but
filters appears to be a public variable.
>>> del warnings.filters[0]
""" """
class InvalidationTests(unittest.TestCase): class InvalidationTests(unittest.TestCase):
......
...@@ -20,7 +20,7 @@ class WarningsHook: ...@@ -20,7 +20,7 @@ class WarningsHook:
application code, allowing the application to customize the way it application code, allowing the application to customize the way it
handles warnings. handles warnings.
This hook captures the unformatted warning information and stored This hook captures the unformatted warning information and stores
it in a list. A test can inspect this list after the test is over. it in a list. A test can inspect this list after the test is over.
Issues: Issues:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment