]> granicus.if.org Git - python/commitdiff
#17143: fix a missing import in the trace module. Initial patch by Berker Peksag.
authorEzio Melotti <ezio.melotti@gmail.com>
Fri, 15 Feb 2013 19:20:50 +0000 (21:20 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Fri, 15 Feb 2013 19:20:50 +0000 (21:20 +0200)
Lib/test/test_trace.py
Lib/trace.py
Misc/NEWS

index ac3a1a30da8531c691691f42d3ffc26ea7196a6b..b2cd728f687519e1d468f02389ef3b87430b8871 100644 (file)
@@ -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__)
 
index 317b5fd6c8bf4bac96f080138391f3e30b794612..c09b365a0147d3e5e474d420314092327d80b2d8 100644 (file)
@@ -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:
index 616ce65822ad29226f227a8d74a2a021cd2aeb06..ba2188637f8fbab975c774217f4e136375e94747 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -178,6 +178,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #17143: Fix a missing import in the trace module.  Initial patch by
+  Berker Peksag.
+
 - Issue #16743: Fix mmap overflow check on 32 bit Windows.
 
 - Issue #16800: tempfile.gettempdir() no longer left temporary files when