Skip to content

Commit f6d755b

Browse files
committed
mark failing tests
1 parent 0fbe6ce commit f6d755b

File tree

2 files changed

+55
-20
lines changed

2 files changed

+55
-20
lines changed

Lib/test/test_exception_group.py

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,33 @@ def assertMatchesTemplate(self, exc, exc_type, template):
300300
self.assertEqual(type(exc), type(template))
301301
self.assertEqual(exc.args, template.args)
302302

303+
class Predicate:
304+
def __init__(self, func):
305+
self.func = func
306+
307+
def __call__(self, e):
308+
return self.func(e)
309+
310+
def method(self, e):
311+
return self.func(e)
303312

304313
class ExceptionGroupSubgroupTests(ExceptionGroupTestBase):
305314
def setUp(self):
306315
self.eg = create_simple_eg()
307316
self.eg_template = [ValueError(1), TypeError(int), ValueError(2)]
308317

318+
# TODO: RUSTPYTHON
319+
@unittest.expectedFailure
309320
def test_basics_subgroup_split__bad_arg_type(self):
321+
class C:
322+
pass
323+
310324
bad_args = ["bad arg",
325+
C,
311326
OSError('instance not type'),
312327
[OSError, TypeError],
313-
(OSError, 42)]
328+
(OSError, 42),
329+
]
314330
for arg in bad_args:
315331
with self.assertRaises(TypeError):
316332
self.eg.subgroup(arg)
@@ -342,10 +358,14 @@ def test_basics_subgroup_by_type__match(self):
342358
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
343359

344360
def test_basics_subgroup_by_predicate__passthrough(self):
345-
self.assertIs(self.eg, self.eg.subgroup(lambda e: True))
361+
f = lambda e: True
362+
for callable in [f, Predicate(f), Predicate(f).method]:
363+
self.assertIs(self.eg, self.eg.subgroup(callable))
346364

347365
def test_basics_subgroup_by_predicate__no_match(self):
348-
self.assertIsNone(self.eg.subgroup(lambda e: False))
366+
f = lambda e: False
367+
for callable in [f, Predicate(f), Predicate(f).method]:
368+
self.assertIsNone(self.eg.subgroup(callable))
349369

350370
def test_basics_subgroup_by_predicate__match(self):
351371
eg = self.eg
@@ -356,9 +376,12 @@ def test_basics_subgroup_by_predicate__match(self):
356376
((ValueError, TypeError), self.eg_template)]
357377

358378
for match_type, template in testcases:
359-
subeg = eg.subgroup(lambda e: isinstance(e, match_type))
360-
self.assertEqual(subeg.message, eg.message)
361-
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
379+
f = lambda e: isinstance(e, match_type)
380+
for callable in [f, Predicate(f), Predicate(f).method]:
381+
with self.subTest(callable=callable):
382+
subeg = eg.subgroup(f)
383+
self.assertEqual(subeg.message, eg.message)
384+
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
362385

363386

364387
class ExceptionGroupSplitTests(ExceptionGroupTestBase):
@@ -405,14 +428,18 @@ def test_basics_split_by_type__match(self):
405428
self.assertIsNone(rest)
406429

407430
def test_basics_split_by_predicate__passthrough(self):
408-
match, rest = self.eg.split(lambda e: True)
409-
self.assertMatchesTemplate(match, ExceptionGroup, self.eg_template)
410-
self.assertIsNone(rest)
431+
f = lambda e: True
432+
for callable in [f, Predicate(f), Predicate(f).method]:
433+
match, rest = self.eg.split(callable)
434+
self.assertMatchesTemplate(match, ExceptionGroup, self.eg_template)
435+
self.assertIsNone(rest)
411436

412437
def test_basics_split_by_predicate__no_match(self):
413-
match, rest = self.eg.split(lambda e: False)
414-
self.assertIsNone(match)
415-
self.assertMatchesTemplate(rest, ExceptionGroup, self.eg_template)
438+
f = lambda e: False
439+
for callable in [f, Predicate(f), Predicate(f).method]:
440+
match, rest = self.eg.split(callable)
441+
self.assertIsNone(match)
442+
self.assertMatchesTemplate(rest, ExceptionGroup, self.eg_template)
416443

417444
def test_basics_split_by_predicate__match(self):
418445
eg = self.eg
@@ -426,20 +453,22 @@ def test_basics_split_by_predicate__match(self):
426453
]
427454

428455
for match_type, match_template, rest_template in testcases:
429-
match, rest = eg.split(lambda e: isinstance(e, match_type))
430-
self.assertEqual(match.message, eg.message)
431-
self.assertMatchesTemplate(
432-
match, ExceptionGroup, match_template)
433-
if rest_template is not None:
434-
self.assertEqual(rest.message, eg.message)
456+
f = lambda e: isinstance(e, match_type)
457+
for callable in [f, Predicate(f), Predicate(f).method]:
458+
match, rest = eg.split(callable)
459+
self.assertEqual(match.message, eg.message)
435460
self.assertMatchesTemplate(
436-
rest, ExceptionGroup, rest_template)
461+
match, ExceptionGroup, match_template)
462+
if rest_template is not None:
463+
self.assertEqual(rest.message, eg.message)
464+
self.assertMatchesTemplate(
465+
rest, ExceptionGroup, rest_template)
437466

438467

439468
class DeepRecursionInSplitAndSubgroup(unittest.TestCase):
440469
def make_deep_eg(self):
441470
e = TypeError(1)
442-
for i in range(C_RECURSION_LIMIT + 1):
471+
for i in range(get_c_recursion_limit() + 1):
443472
e = ExceptionGroup('eg', [e])
444473
return e
445474

Lib/test/test_exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,8 @@ class AssertionErrorTests(unittest.TestCase):
20642064
def tearDown(self):
20652065
unlink(TESTFN)
20662066

2067+
# TODO: RUSTPYTHON
2068+
@unittest.expectedFailure
20672069
@force_not_colorized
20682070
def test_assertion_error_location(self):
20692071
cases = [
@@ -2162,6 +2164,8 @@ def test_assertion_error_location(self):
21622164
result = run_script(source)
21632165
self.assertEqual(result[-3:], expected)
21642166

2167+
# TODO: RUSTPYTHON
2168+
@unittest.expectedFailure
21652169
@force_not_colorized
21662170
def test_multiline_not_highlighted(self):
21672171
cases = [
@@ -2376,6 +2380,8 @@ def try_compile(source):
23762380
self.assertEqual(exc.offset, 1)
23772381
self.assertEqual(exc.end_offset, 12)
23782382

2383+
# TODO: RUSTPYTHON
2384+
@unittest.expectedFailure
23792385
def test_file_source(self):
23802386
self.addCleanup(unlink, TESTFN)
23812387
err = run_script('return "ä"')

0 commit comments

Comments
 (0)