|
17 | 17 | "Test only runs when _remote_debugging is available" |
18 | 18 | ) |
19 | 19 |
|
20 | | -from test.support import force_not_colorized_test_class |
| 20 | +from test.support import force_colorized, force_not_colorized_test_class |
21 | 21 |
|
22 | 22 |
|
23 | 23 | def print_sampled_stats(stats, sort=-1, limit=None, show_summary=True, sample_interval_usec=100): |
@@ -484,6 +484,15 @@ def test_print_sampled_stats_basic(self): |
484 | 484 | self.assertIn("func1", result) |
485 | 485 | self.assertIn("func2", result) |
486 | 486 | self.assertIn("func3", result) |
| 487 | + self.assertNotIn("\x1b[", result) |
| 488 | + |
| 489 | + @force_colorized |
| 490 | + def test_print_sampled_stats_colorized(self): |
| 491 | + with io.StringIO() as output, mock.patch("sys.stdout", output): |
| 492 | + print_sampled_stats(self.mock_stats) |
| 493 | + result = output.getvalue() |
| 494 | + |
| 495 | + self.assertIn("\x1b[1;34mProfile Stats:", result) |
487 | 496 |
|
488 | 497 | def test_print_sampled_stats_sorting(self): |
489 | 498 | """Test different sorting options.""" |
@@ -751,6 +760,7 @@ def test_print_sampled_stats_sort_by_name(self): |
751 | 760 | and not "calls" in line # Skip summary lines |
752 | 761 | and not "total time" in line # Skip summary lines |
753 | 762 | and not "cumulative time" in line |
| 763 | + and not "filename:lineno(function)" in line # Skip header line |
754 | 764 | ): # Skip summary lines |
755 | 765 | data_lines.append(line) |
756 | 766 |
|
|
0 commit comments