Skip to content

Commit a5e4ff0

Browse files
committed
Simplify test
1 parent 8888083 commit a5e4ff0

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

Lib/test/test_repl.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -501,30 +501,8 @@ def test_quiet_mode(self):
501501
self.assertEqual(p.returncode, 0)
502502
self.assertEqual(output[:3], ">>>")
503503

504-
def test_pythonstartup_success(self):
505-
startup_code = dedent("print('notice from pythonstartup in asyncio repl')")
506-
startup_env = self.enterContext(
507-
new_pythonstartup_env(code=startup_code, histfile=".asyncio_history"))
508-
509-
p = spawn_repl(
510-
"-qm", "asyncio",
511-
env=os.environ | startup_env,
512-
isolated=False,
513-
custom=True)
514-
p.stdin.write("1/0")
515-
output = kill_python(p)
516-
self.assertStartsWith(output, 'notice from pythonstartup in asyncio repl')
517-
518-
expected = dedent("""\
519-
File "<stdin>", line 1, in <module>
520-
1/0
521-
~^~
522-
ZeroDivisionError: division by zero
523-
""")
524-
self.assertIn(expected, output)
525-
526504
def test_pythonstartup_failure(self):
527-
startup_code = "def foo():\n 1/0\n"
505+
startup_code = "1/0\n"
528506
startup_env = self.enterContext(
529507
new_pythonstartup_env(code=startup_code, histfile=".asyncio_history"))
530508

@@ -533,18 +511,16 @@ def test_pythonstartup_failure(self):
533511
env=os.environ | startup_env,
534512
isolated=False,
535513
custom=True)
536-
p.stdin.write("foo()")
514+
p.stdin.write("print('executed user code anyway')")
537515
output = kill_python(p)
538516
expected = dedent(f"""\
539-
File "<stdin>", line 1, in <module>
540-
foo()
541-
~~~^^
542-
File "{startup_env['PYTHONSTARTUP']}", line 2, in foo
517+
File "{startup_env['PYTHONSTARTUP']}", line 1, in <module>
543518
1/0
544519
~^~
545520
ZeroDivisionError: division by zero
546521
""")
547522
self.assertIn(expected, output)
523+
self.assertIn("executed user code anyway", output)
548524

549525
if __name__ == "__main__":
550526
unittest.main()

0 commit comments

Comments
 (0)