Skip to content

Commit f938ec8

Browse files
committed
Fix skipping class/module corner cases
1 parent 31a32ca commit f938ec8

File tree

1 file changed

+7
-3
lines changed
  • graalpython/com.oracle.graal.python.test/src

1 file changed

+7
-3
lines changed

graalpython/com.oracle.graal.python.test/src/runner.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def from_str(cls, s: str):
135135
@classmethod
136136
def from_test_case(cls, test_file: Path, test: unittest.TestCase):
137137
test_id = test.id()
138-
if type(test).__name__ == '_ErrorHolder':
138+
if type(test).__module__ == 'unittest.suite' and type(test).__name__ == '_ErrorHolder':
139139
if match := re.match(r'(\S+) \(([^)]+)\)', test_id):
140140
action = match.group(1)
141141
class_name = match.group(2)
@@ -641,10 +641,10 @@ def process_event(self, event):
641641
self.last_test_id_for_blame = test_id
642642
self.last_out_pos = event['out_pos']
643643
if test_id.test_name.endswith('>'):
644-
class_name = test_id.test_name[:test_id.test_name.find('<')]
644+
class_name = test_id.test_name[:test_id.test_name.find('<')].rstrip('.')
645645
specifier = TestSpecifier(test_id.test_file, class_name or None)
646646
self.remaining_test_ids = [
647-
test for test in self.remaining_test_ids if not specifier.match(test_id)
647+
test for test in self.remaining_test_ids if not specifier.match(test)
648648
]
649649

650650
def get_status(self):
@@ -966,6 +966,10 @@ def filter_tree(test_file: TestFile, test_suite: unittest.TestSuite, specifiers:
966966
# When test loading fails, unittest just creates an instance of _FailedTest
967967
if exception := getattr(test, '_exception', None):
968968
raise exception
969+
if type(test).__module__ == 'unittest.loader' and type(test).__name__ == 'ModuleSkipped':
970+
skipped_test, reason = test().skipped[0]
971+
log(f"Test module {skipped_test.id().removeprefix('unittest.loader.ModuleSkipped.')} skipped: {reason}")
972+
return
969973
if hasattr(test, '__iter__'):
970974
sub_collected = filter_tree(test_file, test, specifiers, tagged_ids)
971975
if sub_collected:

0 commit comments

Comments
 (0)