Skip to content

Commit 43824e3

Browse files
committed
Change Lib/test/test_exceptions.py runable
1 parent 4030ad1 commit 43824e3

File tree

1 file changed

+62
-27
lines changed

1 file changed

+62
-27
lines changed

Lib/test/test_exceptions.py

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def check(self, src, lineno, offset, end_lineno=None, end_offset=None, encoding=
219219
line = src.split('\n')[lineno-1]
220220
self.assertIn(line, cm.exception.text)
221221

222+
# TODO: RUSTPYTHON
223+
@unittest.expectedFailure
222224
def test_error_offset_continuation_characters(self):
223225
check = self.check
224226
check('"\\\n"(1 for c in I,\\\n\\', 2, 2)
@@ -672,6 +674,8 @@ def test_str(self):
672674
self.assertTrue(str(Exception('a')))
673675
self.assertTrue(str(Exception('a', 'b')))
674676

677+
# TODO: RUSTPYTHON
678+
@unittest.expectedFailure
675679
def test_exception_cleanup_names(self):
676680
# Make sure the local variable bound to the exception instance by
677681
# an "except" statement is only visible inside the except block.
@@ -1063,6 +1067,9 @@ class C(Exception):
10631067
self.assertIs(c.__context__, b)
10641068
self.assertIsNone(b.__context__)
10651069

1070+
1071+
# TODO: RUSTPYTHON
1072+
@unittest.skip("Infinite loop")
10661073
def test_no_hang_on_context_chain_cycle1(self):
10671074
# See issue 25782. Cycle in context chain.
10681075

@@ -1119,6 +1126,8 @@ class C(Exception):
11191126
self.assertIs(b.__context__, a)
11201127
self.assertIs(a.__context__, c)
11211128

1129+
# TODO: RUSTPYTHON
1130+
@unittest.skip("Infinite loop")
11221131
def test_no_hang_on_context_chain_cycle3(self):
11231132
# See issue 25782. Longer context chain with cycle.
11241133

@@ -1520,8 +1529,6 @@ def test_errno_ENOTDIR(self):
15201529
os.listdir(__file__)
15211530
self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
15221531

1523-
# TODO: RUSTPYTHON
1524-
@unittest.expectedFailure
15251532
def test_unraisable(self):
15261533
# Issue #22836: PyErr_WriteUnraisable() should give sensible reports
15271534
class BrokenDel:
@@ -1634,6 +1641,8 @@ def g():
16341641
next(i)
16351642
next(i)
16361643

1644+
# TODO: RUSTPYTHON
1645+
@unittest.expectedFailure
16371646
@unittest.skipUnless(__debug__, "Won't work if __debug__ is False")
16381647
def test_assert_shadowing(self):
16391648
# Shadowing AssertionError would cause the assert statement to
@@ -1955,36 +1964,38 @@ def foo():
19551964

19561965
self.assertNotIn("something", err.getvalue())
19571966

1958-
def test_issue45826(self):
1959-
# regression test for bpo-45826
1960-
def f():
1961-
with self.assertRaisesRegex(NameError, 'aaa'):
1962-
aab
1967+
# TODO: RUSTPYTHON
1968+
# def test_issue45826(self):
1969+
# # regression test for bpo-45826
1970+
# def f():
1971+
# with self.assertRaisesRegex(NameError, 'aaa'):
1972+
# aab
19631973

1964-
try:
1965-
f()
1966-
except self.failureException:
1967-
with support.captured_stderr() as err:
1968-
sys.__excepthook__(*sys.exc_info())
1974+
# try:
1975+
# f()
1976+
# except self.failureException:
1977+
# with support.captured_stderr() as err:
1978+
# sys.__excepthook__(*sys.exc_info())
19691979

1970-
self.assertIn("aab", err.getvalue())
1980+
# self.assertIn("aab", err.getvalue())
19711981

1972-
def test_issue45826_focused(self):
1973-
def f():
1974-
try:
1975-
nonsense
1976-
except BaseException as E:
1977-
E.with_traceback(None)
1978-
raise ZeroDivisionError()
1982+
# TODO: RUSTPYTHON
1983+
# def test_issue45826_focused(self):
1984+
# def f():
1985+
# try:
1986+
# nonsense
1987+
# except BaseException as E:
1988+
# E.with_traceback(None)
1989+
# raise ZeroDivisionError()
19791990

1980-
try:
1981-
f()
1982-
except ZeroDivisionError:
1983-
with support.captured_stderr() as err:
1984-
sys.__excepthook__(*sys.exc_info())
1991+
# try:
1992+
# f()
1993+
# except ZeroDivisionError:
1994+
# with support.captured_stderr() as err:
1995+
# sys.__excepthook__(*sys.exc_info())
19851996

1986-
self.assertIn("nonsense", err.getvalue())
1987-
self.assertIn("ZeroDivisionError", err.getvalue())
1997+
# self.assertIn("nonsense", err.getvalue())
1998+
# self.assertIn("ZeroDivisionError", err.getvalue())
19881999

19892000

19902001
class AttributeErrorTests(unittest.TestCase):
@@ -2240,6 +2251,8 @@ def test_attribute_error_with_bad_name(self):
22402251

22412252
self.assertNotIn("?", err.getvalue())
22422253

2254+
# TODO: RUSTPYTHON
2255+
@unittest.expectedFailure
22432256
def test_attribute_error_inside_nested_getattr(self):
22442257
class A:
22452258
bluch = 1
@@ -2339,6 +2352,8 @@ def test_copy_pickle(self):
23392352
self.assertEqual(exc.path, orig.path)
23402353

23412354
class SyntaxErrorTests(unittest.TestCase):
2355+
# TODO: RUSTPYTHON
2356+
@unittest.expectedFailure
23422357
def test_range_of_offsets(self):
23432358
cases = [
23442359
# Basic range from 2->7
@@ -2429,6 +2444,8 @@ def test_range_of_offsets(self):
24292444
self.assertIn(expected, err.getvalue())
24302445
the_exception = exc
24312446

2447+
# TODO: RUSTPYTHON
2448+
@unittest.expectedFailure
24322449
def test_encodings(self):
24332450
source = (
24342451
'# -*- coding: cp437 -*-\n'
@@ -2458,6 +2475,8 @@ def test_encodings(self):
24582475
finally:
24592476
unlink(TESTFN)
24602477

2478+
# TODO: RUSTPYTHON
2479+
@unittest.expectedFailure
24612480
def test_non_utf8(self):
24622481
# Check non utf-8 characters
24632482
try:
@@ -2470,6 +2489,8 @@ def test_non_utf8(self):
24702489
finally:
24712490
unlink(TESTFN)
24722491

2492+
# TODO: RUSTPYTHON
2493+
@unittest.expectedFailure
24732494
def test_attributes_new_constructor(self):
24742495
args = ("bad.py", 1, 2, "abcdefg", 1, 100)
24752496
the_exception = SyntaxError("bad bad", args)
@@ -2482,6 +2503,8 @@ def test_attributes_new_constructor(self):
24822503
self.assertEqual(error, the_exception.text)
24832504
self.assertEqual("bad bad", the_exception.msg)
24842505

2506+
# TODO: RUSTPYTHON
2507+
@unittest.expectedFailure
24852508
def test_attributes_old_constructor(self):
24862509
args = ("bad.py", 1, 2, "abcdefg")
24872510
the_exception = SyntaxError("bad bad", args)
@@ -2494,6 +2517,8 @@ def test_attributes_old_constructor(self):
24942517
self.assertEqual(error, the_exception.text)
24952518
self.assertEqual("bad bad", the_exception.msg)
24962519

2520+
# TODO: RUSTPYTHON
2521+
@unittest.expectedFailure
24972522
def test_incorrect_constructor(self):
24982523
args = ("bad.py", 1, 2)
24992524
self.assertRaises(TypeError, SyntaxError, "bad bad", args)
@@ -2540,6 +2565,8 @@ def in_except():
25402565
pass
25412566
self.lineno_after_raise(in_except, 4)
25422567

2568+
# TODO: RUSTPYTHON
2569+
@unittest.expectedFailure
25432570
def test_lineno_after_other_except(self):
25442571
def other_except():
25452572
try:
@@ -2557,6 +2584,8 @@ def in_named_except():
25572584
pass
25582585
self.lineno_after_raise(in_named_except, 4)
25592586

2587+
# TODO: RUSTPYTHON
2588+
@unittest.expectedFailure
25602589
def test_lineno_in_try(self):
25612590
def in_try():
25622591
try:
@@ -2583,6 +2612,8 @@ def in_finally_except():
25832612
pass
25842613
self.lineno_after_raise(in_finally_except, 4)
25852614

2615+
# TODO: RUSTPYTHON
2616+
@unittest.expectedFailure
25862617
def test_lineno_after_with(self):
25872618
class Noop:
25882619
def __enter__(self):
@@ -2595,13 +2626,17 @@ def after_with():
25952626
pass
25962627
self.lineno_after_raise(after_with, 2)
25972628

2629+
# TODO: RUSTPYTHON
2630+
@unittest.expectedFailure
25982631
def test_missing_lineno_shows_as_none(self):
25992632
def f():
26002633
1/0
26012634
self.lineno_after_raise(f, 1)
26022635
f.__code__ = f.__code__.replace(co_linetable=b'\x04\x80\xff\x80')
26032636
self.lineno_after_raise(f, None)
26042637

2638+
# TODO: RUSTPYTHON
2639+
@unittest.expectedFailure
26052640
def test_lineno_after_raise_in_with_exit(self):
26062641
class ExitFails:
26072642
def __enter__(self):

0 commit comments

Comments
 (0)