mark failing tests

This commit is contained in:
ShaharNaveh committed 2025-07-16 13:37:18 +03:00
1 parent 0fbe6ce268
commit f6d755b4ff
2 files changed
+55 -20

No files matched your search

+49 -20
View File
@@ -300,17 +300,33 @@ class ExceptionGroupTestBase(unittest.TestCase):
self.assertEqual(type(exc), type(template))
self.assertEqual(exc.args, template.args)
class Predicate:
def __init__(self, func):
self.func = func
def __call__(self, e):
return self.func(e)
def method(self, e):
return self.func(e)
class ExceptionGroupSubgroupTests(ExceptionGroupTestBase):
def setUp(self):
self.eg = create_simple_eg()
self.eg_template = [ValueError(1), TypeError(int), ValueError(2)]
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_basics_subgroup_split__bad_arg_type(self):
class C:
pass
bad_args = ["bad arg",
C,
OSError('instance not type'),
[OSError, TypeError],
(OSError, 42)]
(OSError, 42),
]
for arg in bad_args:
with self.assertRaises(TypeError):
self.eg.subgroup(arg)
@@ -342,10 +358,14 @@ class ExceptionGroupSubgroupTests(ExceptionGroupTestBase):
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
def test_basics_subgroup_by_predicate__passthrough(self):
self.assertIs(self.eg, self.eg.subgroup(lambda e: True))
f = lambda e: True
for callable in [f, Predicate(f), Predicate(f).method]:
self.assertIs(self.eg, self.eg.subgroup(callable))
def test_basics_subgroup_by_predicate__no_match(self):
self.assertIsNone(self.eg.subgroup(lambda e: False))
f = lambda e: False
for callable in [f, Predicate(f), Predicate(f).method]:
self.assertIsNone(self.eg.subgroup(callable))
def test_basics_subgroup_by_predicate__match(self):
eg = self.eg
@@ -356,9 +376,12 @@ class ExceptionGroupSubgroupTests(ExceptionGroupTestBase):
((ValueError, TypeError), self.eg_template)]
for match_type, template in testcases:
subeg = eg.subgroup(lambda e: isinstance(e, match_type))
self.assertEqual(subeg.message, eg.message)
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
f = lambda e: isinstance(e, match_type)
for callable in [f, Predicate(f), Predicate(f).method]:
with self.subTest(callable=callable):
subeg = eg.subgroup(f)
self.assertEqual(subeg.message, eg.message)
self.assertMatchesTemplate(subeg, ExceptionGroup, template)
class ExceptionGroupSplitTests(ExceptionGroupTestBase):
@@ -405,14 +428,18 @@ class ExceptionGroupSplitTests(ExceptionGroupTestBase):
self.assertIsNone(rest)
def test_basics_split_by_predicate__passthrough(self):
match, rest = self.eg.split(lambda e: True)
self.assertMatchesTemplate(match, ExceptionGroup, self.eg_template)
self.assertIsNone(rest)
f = lambda e: True
for callable in [f, Predicate(f), Predicate(f).method]:
match, rest = self.eg.split(callable)
self.assertMatchesTemplate(match, ExceptionGroup, self.eg_template)
self.assertIsNone(rest)
def test_basics_split_by_predicate__no_match(self):
match, rest = self.eg.split(lambda e: False)
self.assertIsNone(match)
self.assertMatchesTemplate(rest, ExceptionGroup, self.eg_template)
f = lambda e: False
for callable in [f, Predicate(f), Predicate(f).method]:
match, rest = self.eg.split(callable)
self.assertIsNone(match)
self.assertMatchesTemplate(rest, ExceptionGroup, self.eg_template)
def test_basics_split_by_predicate__match(self):
eg = self.eg
@@ -426,20 +453,22 @@ class ExceptionGroupSplitTests(ExceptionGroupTestBase):
]
for match_type, match_template, rest_template in testcases:
match, rest = eg.split(lambda e: isinstance(e, match_type))
self.assertEqual(match.message, eg.message)
self.assertMatchesTemplate(
match, ExceptionGroup, match_template)
if rest_template is not None:
self.assertEqual(rest.message, eg.message)
f = lambda e: isinstance(e, match_type)
for callable in [f, Predicate(f), Predicate(f).method]:
match, rest = eg.split(callable)
self.assertEqual(match.message, eg.message)
self.assertMatchesTemplate(
rest, ExceptionGroup, rest_template)
match, ExceptionGroup, match_template)
if rest_template is not None:
self.assertEqual(rest.message, eg.message)
self.assertMatchesTemplate(
rest, ExceptionGroup, rest_template)
class DeepRecursionInSplitAndSubgroup(unittest.TestCase):
def make_deep_eg(self):
e = TypeError(1)
for i in range(C_RECURSION_LIMIT + 1):
for i in range(get_c_recursion_limit() + 1):
e = ExceptionGroup('eg', [e])
return e
+6
View File
@@ -2064,6 +2064,8 @@ class AssertionErrorTests(unittest.TestCase):
def tearDown(self):
unlink(TESTFN)
# TODO: RUSTPYTHON
@unittest.expectedFailure
@force_not_colorized
def test_assertion_error_location(self):
cases = [
@@ -2162,6 +2164,8 @@ class AssertionErrorTests(unittest.TestCase):
result = run_script(source)
self.assertEqual(result[-3:], expected)
# TODO: RUSTPYTHON
@unittest.expectedFailure
@force_not_colorized
def test_multiline_not_highlighted(self):
cases = [
@@ -2376,6 +2380,8 @@ class SyntaxErrorTests(unittest.TestCase):
self.assertEqual(exc.offset, 1)
self.assertEqual(exc.end_offset, 12)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_file_source(self):
self.addCleanup(unlink, TESTFN)
err = run_script('return "ä"')