diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-02-15 19:22:22 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-02-15 19:22:22 (GMT) |
commit | 10f89329adac0a405b5416727c0df6bd4ba6a17d (patch) | |
tree | 58043f368eb2ada2c34340226f286948841e7cee /Lib | |
parent | 990f69e6038f9e8b306708a41ec841b930042973 (diff) | |
parent | 23e043fdcd52c2bdcde40b07f21e56ab8a956cff (diff) | |
download | cpython-10f89329adac0a405b5416727c0df6bd4ba6a17d.zip cpython-10f89329adac0a405b5416727c0df6bd4ba6a17d.tar.gz cpython-10f89329adac0a405b5416727c0df6bd4ba6a17d.tar.bz2 |
#17143: merge with 3.3.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_trace.py | 45 | ||||
-rw-r--r-- | Lib/trace.py | 1 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index ac3a1a3..b2cd728 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,7 +1,9 @@ import os +import io import sys from test.support import (run_unittest, TESTFN, rmtree, unlink, captured_stdout) +import tempfile import unittest import trace @@ -361,6 +363,49 @@ class Test_Ignore(unittest.TestCase): self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) +class TestDeprecatedMethods(unittest.TestCase): + + def test_deprecated_usage(self): + sio = io.StringIO() + with self.assertWarns(DeprecationWarning): + trace.usage(sio) + self.assertIn('Usage:', sio.getvalue()) + + def test_deprecated_Ignore(self): + with self.assertWarns(DeprecationWarning): + trace.Ignore() + + def test_deprecated_modname(self): + with self.assertWarns(DeprecationWarning): + self.assertEqual("spam", trace.modname("spam")) + + def test_deprecated_fullmodname(self): + with self.assertWarns(DeprecationWarning): + self.assertEqual("spam", trace.fullmodname("spam")) + + def test_deprecated_find_lines_from_code(self): + with self.assertWarns(DeprecationWarning): + def foo(): + pass + trace.find_lines_from_code(foo.__code__, ["eggs"]) + + def test_deprecated_find_lines(self): + with self.assertWarns(DeprecationWarning): + def foo(): + pass + trace.find_lines(foo.__code__, ["eggs"]) + + def test_deprecated_find_strings(self): + with self.assertWarns(DeprecationWarning): + with tempfile.NamedTemporaryFile() as fd: + trace.find_strings(fd.name) + + def test_deprecated_find_executable_linenos(self): + with self.assertWarns(DeprecationWarning): + with tempfile.NamedTemporaryFile() as fd: + trace.find_executable_linenos(fd.name) + + def test_main(): run_unittest(__name__) diff --git a/Lib/trace.py b/Lib/trace.py index 7eb35eb..09fe9ee 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -58,6 +58,7 @@ import inspect import gc import dis import pickle +from warnings import warn as _warn try: from time import monotonic as _time except ImportError: |