diff options
| author | Brett Cannon <bcannon@gmail.com> | 2008-05-05 05:32:07 (GMT) |
|---|---|---|
| committer | Brett Cannon <bcannon@gmail.com> | 2008-05-05 05:32:07 (GMT) |
| commit | 8a232cc385343c17d9f615f0aff49fc378bdebae (patch) | |
| tree | 35dbd69774e9a32275293638dcfaeb322dc8790b /Lib/test/test_warnings.py | |
| parent | 9ae080ee5acad3c6207db75843cf1a27f868c540 (diff) | |
| download | cpython-8a232cc385343c17d9f615f0aff49fc378bdebae.zip cpython-8a232cc385343c17d9f615f0aff49fc378bdebae.tar.gz cpython-8a232cc385343c17d9f615f0aff49fc378bdebae.tar.bz2 | |
Add a DeprecationWarning for when warnings.showwarning() is set to a function
that lacks support for the new 'line' argument.
Diffstat (limited to 'Lib/test/test_warnings.py')
| -rw-r--r-- | Lib/test/test_warnings.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 5df0b90..c854d7a 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -461,6 +461,32 @@ class PyWarningsDisplayTests(BaseTest, WarningsDisplayTests): module = py_warnings +class ShowwarningDeprecationTests(BaseTest): + + """Test the deprecation of the old warnings.showwarning() API works.""" + + @staticmethod + def bad_showwarning(message, category, filename, lineno, file=None): + pass + + def test_deprecation(self): + # message, category, filename, lineno[, file[, line]] + args = ("message", UserWarning, "file name", 42) + with test_support.catch_warning(self.module): + self.module.filterwarnings("error", category=DeprecationWarning) + self.module.showwarning = self.bad_showwarning + self.assertRaises(DeprecationWarning, self.module.warn_explicit, + *args) + +class CShowwarningDeprecationTests(ShowwarningDeprecationTests): + module = c_warnings + + +class PyShowwarningDeprecationTests(ShowwarningDeprecationTests): + module = py_warnings + + + def test_main(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() @@ -471,6 +497,8 @@ def test_main(): CWCmdLineTests, PyWCmdLineTests, _WarningsTests, CWarningsDisplayTests, PyWarningsDisplayTests, + CShowwarningDeprecationTests, + PyShowwarningDeprecationTests, ) |
