LEFT | RIGHT |
1 import os | 1 import os |
| 2 import io |
2 import sys | 3 import sys |
3 from test.support import (run_unittest, TESTFN, rmtree, unlink, | 4 from test.support import (run_unittest, TESTFN, rmtree, unlink, |
4 captured_stdout) | 5 captured_stdout) |
5 import unittest | 6 import unittest |
6 | 7 |
7 import trace | 8 import trace |
8 from trace import CoverageResults, Trace | 9 from trace import CoverageResults, Trace |
9 | 10 |
10 from test.tracedmodules import testmod | 11 from test.tracedmodules import testmod |
11 | 12 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')]) | 355 ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')]) |
355 self.assertTrue(ignore.names('x.py', 'x')) | 356 self.assertTrue(ignore.names('x.py', 'x')) |
356 self.assertFalse(ignore.names('xy.py', 'xy')) | 357 self.assertFalse(ignore.names('xy.py', 'xy')) |
357 self.assertFalse(ignore.names('y.py', 'y')) | 358 self.assertFalse(ignore.names('y.py', 'y')) |
358 self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz')) | 359 self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz')) |
359 self.assertFalse(ignore.names(jn('bar', 'z.py'), 'z')) | 360 self.assertFalse(ignore.names(jn('bar', 'z.py'), 'z')) |
360 # Matched before. | 361 # Matched before. |
361 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) | 362 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) |
362 | 363 |
363 | 364 |
| 365 class TestDeprecatedMethods(unittest.TestCase): |
| 366 |
| 367 def test_deprecated_usage(self): |
| 368 sio = io.StringIO() |
| 369 with self.assertWarns(DeprecationWarning): |
| 370 trace.usage(sio) |
| 371 self.assertIn('Usage:', sio.getvalue()) |
| 372 |
| 373 def test_deprecated_Ignore(self): |
| 374 with self.assertWarns(DeprecationWarning): |
| 375 trace.Ignore() |
| 376 |
| 377 def test_deprecated_modname(self): |
| 378 with self.assertWarns(DeprecationWarning): |
| 379 self.assertEqual("spam", trace.modname("spam")) |
| 380 |
| 381 def test_deprecated_fullmodname(self): |
| 382 with self.assertWarns(DeprecationWarning): |
| 383 self.assertEqual("spam", trace.fullmodname("spam")) |
| 384 |
| 385 def test_deprecated_find_lines_from_code(self): |
| 386 with self.assertWarns(DeprecationWarning): |
| 387 def foo(): |
| 388 pass |
| 389 trace.find_lines_from_code(foo.__code__, ["eggs"]) |
| 390 |
| 391 def test_deprecated_find_lines(self): |
| 392 with self.assertWarns(DeprecationWarning): |
| 393 def foo(): |
| 394 pass |
| 395 trace.find_lines(foo.__code__, ["eggs"]) |
| 396 |
| 397 def test_deprecated_find_strings(self): |
| 398 with open(TESTFN, 'w') as fd: |
| 399 self.addCleanup(unlink, TESTFN) |
| 400 with self.assertWarns(DeprecationWarning): |
| 401 trace.find_strings(fd.name) |
| 402 |
| 403 def test_deprecated_find_executable_linenos(self): |
| 404 with open(TESTFN, 'w') as fd: |
| 405 self.addCleanup(unlink, TESTFN) |
| 406 with self.assertWarns(DeprecationWarning): |
| 407 trace.find_executable_linenos(fd.name) |
| 408 |
| 409 |
364 def test_main(): | 410 def test_main(): |
365 run_unittest(__name__) | 411 run_unittest(__name__) |
366 | 412 |
367 | 413 |
368 if __name__ == '__main__': | 414 if __name__ == '__main__': |
369 test_main() | 415 test_main() |
LEFT | RIGHT |