summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-02-15 21:20:50 +0200
committerEzio Melotti <ezio.melotti@gmail.com>2013-02-15 21:20:50 +0200
commit7bb19604d2a0f101ea14ef760d4dffef609ee4e9 (patch)
treeb70bc92f07989d487ad079ff85d3516197b066ac
parent3f9d0436c60c35983d0f269b73ca9233f7c340f4 (diff)
downloadcpython-7bb19604d2a0f101ea14ef760d4dffef609ee4e9.tar.gz
#17143: fix a missing import in the trace module. Initial patch by Berker Peksag.
-rw-r--r--Lib/test/test_trace.py45
-rw-r--r--Lib/trace.py1
-rw-r--r--Misc/NEWS3
3 files changed, 49 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index ac3a1a30da..b2cd728f68 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 317b5fd6c8..c09b365a01 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:
diff --git a/Misc/NEWS b/Misc/NEWS
index 616ce65822..ba2188637f 100644
--- 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