MCPcopy Create free account
hub / github.com/python/cpython / normalize_test_name

Function normalize_test_name

Lib/test/libregrtest/utils.py:546–565  ·  view source on GitHub ↗
(test_full_name: str, *,
                        is_error: bool = False)

Source from the content-addressed store, hash-verified

544))
545
546def normalize_test_name(test_full_name: str, *,
547 is_error: bool = False) -> str | None:
548 short_name = test_full_name.split(" ")[0]
549 if is_error and short_name in _TEST_LIFECYCLE_HOOKS:
550 if test_full_name.startswith(('setUpModule (', 'tearDownModule (')):
551 # if setUpModule() or tearDownModule() failed, don't filter
552 # tests with the test file name, don't use filters.
553 return None
554
555 # This means that we have a failure in a life-cycle hook,
556 # we need to rerun the whole module or class suite.
557 # Basically the error looks like this:
558 # ERROR: setUpClass (test.test_reg_ex.RegTest)
559 # or
560 # ERROR: setUpModule (test.test_reg_ex)
561 # So, we need to parse the class / module name.
562 lpar = test_full_name.index('(')
563 rpar = test_full_name.index(')')
564 return test_full_name[lpar + 1: rpar].split('.')[-1]
565 return short_name
566
567
568def adjust_rlimit_nofile() -> None:

Callers 1

get_rerun_match_testsMethod · 0.85

Calls 3

splitMethod · 0.45
startswithMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…