Skip to content

Commit 588d9fb

Browse files
authored
pythongh-136438: Make sure test_remote_pdb pass with all optimization levels (pythonGH-136788)
1 parent 6be49ee commit 588d9fb

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

Lib/test/test_remote_pdb.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest
1212
import unittest.mock
1313
from contextlib import closing, contextmanager, redirect_stdout, redirect_stderr, ExitStack
14-
from test.support import is_wasi, cpython_only, force_color, requires_subprocess, SHORT_TIMEOUT
14+
from test.support import is_wasi, cpython_only, force_color, requires_subprocess, SHORT_TIMEOUT, subTests
1515
from test.support.os_helper import TESTFN, unlink
1616
from typing import List
1717

@@ -279,37 +279,50 @@ def test_handling_other_message(self):
279279
expected_stdout="Some message.\n",
280280
)
281281

282-
def test_handling_help_for_command(self):
283-
"""Test handling a request to display help for a command."""
282+
@unittest.skipIf(sys.flags.optimize >= 2, "Help not available for -OO")
283+
@subTests(
284+
"help_request,expected_substring",
285+
[
286+
# a request to display help for a command
287+
({"help": "ll"}, "Usage: ll | longlist"),
288+
# a request to display a help overview
289+
({"help": ""}, "type help <topic>"),
290+
# a request to display the full PDB manual
291+
({"help": "pdb"}, ">>> import pdb"),
292+
],
293+
)
294+
def test_handling_help_when_available(self, help_request, expected_substring):
295+
"""Test handling help requests when help is available."""
284296
incoming = [
285-
("server", {"help": "ll"}),
297+
("server", help_request),
286298
]
287299
self.do_test(
288300
incoming=incoming,
289301
expected_outgoing=[],
290-
expected_stdout_substring="Usage: ll | longlist",
302+
expected_stdout_substring=expected_substring,
291303
)
292304

293-
def test_handling_help_without_a_specific_topic(self):
294-
"""Test handling a request to display a help overview."""
305+
@unittest.skipIf(sys.flags.optimize < 2, "Needs -OO")
306+
@subTests(
307+
"help_request,expected_substring",
308+
[
309+
# a request to display help for a command
310+
({"help": "ll"}, "No help for 'll'"),
311+
# a request to display a help overview
312+
({"help": ""}, "Undocumented commands"),
313+
# a request to display the full PDB manual
314+
({"help": "pdb"}, "No help for 'pdb'"),
315+
],
316+
)
317+
def test_handling_help_when_not_available(self, help_request, expected_substring):
318+
"""Test handling help requests when help is not available."""
295319
incoming = [
296-
("server", {"help": ""}),
320+
("server", help_request),
297321
]
298322
self.do_test(
299323
incoming=incoming,
300324
expected_outgoing=[],
301-
expected_stdout_substring="type help <topic>",
302-
)
303-
304-
def test_handling_help_pdb(self):
305-
"""Test handling a request to display the full PDB manual."""
306-
incoming = [
307-
("server", {"help": "pdb"}),
308-
]
309-
self.do_test(
310-
incoming=incoming,
311-
expected_outgoing=[],
312-
expected_stdout_substring=">>> import pdb",
325+
expected_stdout_substring=expected_substring,
313326
)
314327

315328
def test_handling_pdb_prompts(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy