Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,8 @@ def test_errors_in_command(self):
])
stdout, _ = self.run_pdb_script('pass', commands + '\n')

self.assertEqual(stdout.splitlines()[1:], [
stdout_lines = stdout.splitlines()[1:]
expected_lines = [
'-> pass',
'(Pdb) *** SyntaxError: \'(\' was never closed',

Expand All @@ -1857,7 +1858,9 @@ def test_errors_in_command(self):
"((Pdb)) *** NameError: name 'doesnotexist' is not defined",
'LEAVING RECURSIVE DEBUGGER',
'(Pdb) ',
])
]
self.assertTrue(all(e == s for (e, s) in zip(stdout_lines, expected_lines)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use a comment explaining why we aren't checking for an exact match.

Also, the use of assertTrue means we won't get a detailed error if the test fails. Perhaps you could loop over the pairs of lines and self.assertEqual for each line instead.

self.assertTrue(len(expected_lines) <= len(stdout_lines) <= len(expected_lines) + 1)

def test_issue34266(self):
'''do_run handles exceptions from parsing its arg'''
Expand All @@ -1867,11 +1870,7 @@ def check(bad_arg, msg):
'q',
])
stdout, _ = self.run_pdb_script('pass', commands + '\n')
self.assertEqual(stdout.splitlines()[1:], [
'-> pass',
f'(Pdb) *** Cannot run {bad_arg}: {msg}',
'(Pdb) ',
])
self.assertIn(f'(Pdb) *** Cannot run {bad_arg}: {msg}', stdout)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to remove the other expected lines?

check('\\', 'No escaped character')
check('"', 'No closing quotation')

Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@ Zero Piraeus
Antoine Pitrou
Jean-François Piéronne
Oleg Plakhotnyuk
Léon Planken
Anatoliy Platonov
Marcel Plch
Remi Pointel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix issue running test_pdb inside GNU `screen`: for some reason, two tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove everything after the first colon, NEWS entries just need to say what the change is, not a detailed motivation.

in test_pdb failed when running inside GNU `screen`. The `screen`
environment injects an ANSI control sequence into the output from `pdb`,
which did not match the expected output.