Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96b531a

Browse files
committed
Issue #26069: Remove the deprecated apis in the trace module.
1 parent f7272a6 commit 96b531a

3 files changed

Lines changed: 3 additions & 90 deletions

File tree

Lib/test/test_trace.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
2-
import io
32
import sys
43
from test.support import TESTFN, rmtree, unlink, captured_stdout
54
import unittest
65

76
import trace
8-
from trace import CoverageResults, Trace
7+
from trace import Trace
98

109
from test.tracedmodules import testmod
1110

@@ -366,50 +365,5 @@ def test_ignored(self):
366365
self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
367366

368367

369-
class TestDeprecatedMethods(unittest.TestCase):
370-
371-
def test_deprecated_usage(self):
372-
sio = io.StringIO()
373-
with self.assertWarns(DeprecationWarning):
374-
trace.usage(sio)
375-
self.assertIn('Usage:', sio.getvalue())
376-
377-
def test_deprecated_Ignore(self):
378-
with self.assertWarns(DeprecationWarning):
379-
trace.Ignore()
380-
381-
def test_deprecated_modname(self):
382-
with self.assertWarns(DeprecationWarning):
383-
self.assertEqual("spam", trace.modname("spam"))
384-
385-
def test_deprecated_fullmodname(self):
386-
with self.assertWarns(DeprecationWarning):
387-
self.assertEqual("spam", trace.fullmodname("spam"))
388-
389-
def test_deprecated_find_lines_from_code(self):
390-
with self.assertWarns(DeprecationWarning):
391-
def foo():
392-
pass
393-
trace.find_lines_from_code(foo.__code__, ["eggs"])
394-
395-
def test_deprecated_find_lines(self):
396-
with self.assertWarns(DeprecationWarning):
397-
def foo():
398-
pass
399-
trace.find_lines(foo.__code__, ["eggs"])
400-
401-
def test_deprecated_find_strings(self):
402-
with open(TESTFN, 'w') as fd:
403-
self.addCleanup(unlink, TESTFN)
404-
with self.assertWarns(DeprecationWarning):
405-
trace.find_strings(fd.name)
406-
407-
def test_deprecated_find_executable_linenos(self):
408-
with open(TESTFN, 'w') as fd:
409-
self.addCleanup(unlink, TESTFN)
410-
with self.assertWarns(DeprecationWarning):
411-
trace.find_executable_linenos(fd.name)
412-
413-
414368
if __name__ == '__main__':
415369
unittest.main()

Lib/trace.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import gc
5959
import dis
6060
import pickle
61-
from warnings import warn as _warn
6261
from time import monotonic as _time
6362

6463
try:
@@ -810,47 +809,5 @@ def main(argv=None):
810809
if not no_report:
811810
results.write_results(missing, summary=summary, coverdir=coverdir)
812811

813-
# Deprecated API
814-
def usage(outfile):
815-
_warn("The trace.usage() function is deprecated",
816-
DeprecationWarning, 2)
817-
_usage(outfile)
818-
819-
class Ignore(_Ignore):
820-
def __init__(self, modules=None, dirs=None):
821-
_warn("The class trace.Ignore is deprecated",
822-
DeprecationWarning, 2)
823-
_Ignore.__init__(self, modules, dirs)
824-
825-
def modname(path):
826-
_warn("The trace.modname() function is deprecated",
827-
DeprecationWarning, 2)
828-
return _modname(path)
829-
830-
def fullmodname(path):
831-
_warn("The trace.fullmodname() function is deprecated",
832-
DeprecationWarning, 2)
833-
return _fullmodname(path)
834-
835-
def find_lines_from_code(code, strs):
836-
_warn("The trace.find_lines_from_code() function is deprecated",
837-
DeprecationWarning, 2)
838-
return _find_lines_from_code(code, strs)
839-
840-
def find_lines(code, strs):
841-
_warn("The trace.find_lines() function is deprecated",
842-
DeprecationWarning, 2)
843-
return _find_lines(code, strs)
844-
845-
def find_strings(filename, encoding=None):
846-
_warn("The trace.find_strings() function is deprecated",
847-
DeprecationWarning, 2)
848-
return _find_strings(filename, encoding=None)
849-
850-
def find_executable_linenos(filename):
851-
_warn("The trace.find_executable_linenos() function is deprecated",
852-
DeprecationWarning, 2)
853-
return _find_executable_linenos(filename)
854-
855812
if __name__=='__main__':
856813
main()

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Core and Builtins
128128
Library
129129
-------
130130

131+
- Issue #26069: Remove the deprecated apis in the trace module.
132+
131133
- Issue #22138: Fix mock.patch behavior when patching descriptors. Restore
132134
original values after patching. Patch contributed by Sean McCully.
133135

0 commit comments

Comments
 (0)