Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/test/libregrtest/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .skipped import expected_to_be_skipped
from .utils import (
StrPath, TestName, TestTuple, TestList, FilterDict,
printlist, count, format_duration)
printlist, count, format_duration, cleanup_test_name)


# Python uses exit code 1 when an exception is not caught
Expand Down Expand Up @@ -98,9 +98,7 @@ def get_exitcode(self, fail_env_changed: bool, fail_rerun: bool) -> int:
return exitcode

def accumulate_result(self, result: TestResult, runtests: RunTests) -> None:
test_name = result.test_name
# Remove "test." prefix added by some test packages
test_name = test_name.removeprefix('test.')
test_name = cleanup_test_name(result.test_name)
rerun = runtests.rerun
fail_env_changed = runtests.fail_env_changed

Expand Down Expand Up @@ -218,6 +216,8 @@ def split_expected_skip(self, tests):
return (skipped, expected)

def display_result(self, tests: TestTuple, quiet: bool, print_slowest: bool) -> None:
tests = tuple(cleanup_test_name(name) for name in tests)

ansi = get_colors()
green = ansi.GREEN
red = ansi.BOLD_RED
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/libregrtest/skipped.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import sysconfig
from test import support
from .utils import cleanup_test_name


# On a WASI CI, the main regrtest process is run on the build Python and test
Expand Down Expand Up @@ -295,7 +296,7 @@

def expected_to_be_skipped(test_name):
# Test EXPECTED_SKIP
test_name = test_name.removeprefix('test.')
test_name = cleanup_test_name(test_name)
if test_name in EXPECTED_SKIP:
return True
package = test_name.split('.')[0]
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
FilterDict = dict[TestName, FilterTuple]


def cleanup_test_name(name: TestName) -> TestName:
return name.removeprefix('test.')


def format_duration(seconds: float) -> str:
ms = math.ceil(seconds * 1e3)
seconds, ms = divmod(ms, 1000)
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,21 @@ def test_sanitize_xml(self):
self.assertEqual(sanitize_xml('valid t\xe9xt \u20ac'),
'valid t\xe9xt \u20ac')

def test_cleanup_test_name(self):
cleanup_test_name = utils.cleanup_test_name

# Strip "test." prefix
self.assertEqual(cleanup_test_name('test.test_asyncio.test_graph'),
'test_asyncio.test_graph')
self.assertEqual(cleanup_test_name('test.test_multiprocessing_spawn.test_manager'),
'test_multiprocessing_spawn.test_manager')

# No change
self.assertEqual(cleanup_test_name('test_cmath'),
'test_cmath')
self.assertEqual(cleanup_test_name('test_asyncio.test_graph'),
'test_asyncio.test_graph')


class GitHubActionsReporterTestCase(unittest.TestCase):
def setUp(self):
Expand Down
Loading