|
1 | 1 | import os
|
| 2 | +import io |
2 | 3 | import sys
|
3 | 4 | from test.support import (run_unittest, TESTFN, rmtree, unlink,
|
4 | 5 | captured_stdout)
|
| 6 | +import tempfile |
5 | 7 | import unittest
|
6 | 8 |
|
7 | 9 | import trace
|
@@ -361,6 +363,49 @@ def test_ignored(self):
|
361 | 363 | self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
|
362 | 364 |
|
363 | 365 |
|
| 366 | +class TestDeprecatedMethods(unittest.TestCase): |
| 367 | + |
| 368 | + def test_deprecated_usage(self): |
| 369 | + sio = io.StringIO() |
| 370 | + with self.assertWarns(DeprecationWarning): |
| 371 | + trace.usage(sio) |
| 372 | + self.assertIn('Usage:', sio.getvalue()) |
| 373 | + |
| 374 | + def test_deprecated_Ignore(self): |
| 375 | + with self.assertWarns(DeprecationWarning): |
| 376 | + trace.Ignore() |
| 377 | + |
| 378 | + def test_deprecated_modname(self): |
| 379 | + with self.assertWarns(DeprecationWarning): |
| 380 | + self.assertEqual("spam", trace.modname("spam")) |
| 381 | + |
| 382 | + def test_deprecated_fullmodname(self): |
| 383 | + with self.assertWarns(DeprecationWarning): |
| 384 | + self.assertEqual("spam", trace.fullmodname("spam")) |
| 385 | + |
| 386 | + def test_deprecated_find_lines_from_code(self): |
| 387 | + with self.assertWarns(DeprecationWarning): |
| 388 | + def foo(): |
| 389 | + pass |
| 390 | + trace.find_lines_from_code(foo.__code__, ["eggs"]) |
| 391 | + |
| 392 | + def test_deprecated_find_lines(self): |
| 393 | + with self.assertWarns(DeprecationWarning): |
| 394 | + def foo(): |
| 395 | + pass |
| 396 | + trace.find_lines(foo.__code__, ["eggs"]) |
| 397 | + |
| 398 | + def test_deprecated_find_strings(self): |
| 399 | + with self.assertWarns(DeprecationWarning): |
| 400 | + with tempfile.NamedTemporaryFile() as fd: |
| 401 | + trace.find_strings(fd.name) |
| 402 | + |
| 403 | + def test_deprecated_find_executable_linenos(self): |
| 404 | + with self.assertWarns(DeprecationWarning): |
| 405 | + with tempfile.NamedTemporaryFile() as fd: |
| 406 | + trace.find_executable_linenos(fd.name) |
| 407 | + |
| 408 | + |
364 | 409 | def test_main():
|
365 | 410 | run_unittest(__name__)
|
366 | 411 |
|
|
0 commit comments