Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Fix #925: Make --host a required switch
Browse files Browse the repository at this point in the history
  • Loading branch information
int19h committed Oct 17, 2018
1 parent cbb5a51 commit bd220d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ptvsd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _parse_args(prog, argv):
parser.add_argument('--nodebug', action='store_true')
parser.add_argument('--client', action='store_true')

parser.add_argument('--host')
parser.add_argument('--host', required=True)
parser.add_argument('--port', type=int, required=True)

target = parser.add_mutually_exclusive_group(required=True)
Expand Down
45 changes: 22 additions & 23 deletions tests/ptvsd/test___main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@ class ParseArgsTests(unittest.TestCase):

EXPECTED_EXTRA = ['--']

def test_module(self):
args, extra = parse_args([
'eggs',
'--port', '8888',
'-m', 'spam',
])

self.assertEqual(vars(args), {
'kind': 'module',
'name': 'spam',
'address': Address.as_server(None, 8888),
'nodebug': False,
'single_session': False,
'wait': False,
})
self.assertEqual(extra, self.EXPECTED_EXTRA)
def test_host_required(self):
with self.assertRaises(SystemExit):
parse_args([
'eggs',
'--port', '8888',
'-m', 'spam',
])

def test_module_server(self):
args, extra = parse_args([
Expand All @@ -49,14 +40,15 @@ def test_module_nodebug(self):
'eggs',
'--nodebug',
'--client',
'--host', 'localhost',
'--port', '8888',
'-m', 'spam',
])

self.assertEqual(vars(args), {
'kind': 'module',
'name': 'spam',
'address': Address.as_client(None, 8888),
'address': Address.as_client('localhost', 8888),
'nodebug': True,
'single_session': False,
'wait': False,
Expand All @@ -66,14 +58,15 @@ def test_module_nodebug(self):
def test_script(self):
args, extra = parse_args([
'eggs',
'--host', 'localhost',
'--port', '8888',
'spam.py',
])

self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam.py',
'address': Address.as_server(None, 8888),
'address': Address.as_server('localhost', 8888),
'nodebug': False,
'single_session': False,
'wait': False,
Expand Down Expand Up @@ -103,14 +96,15 @@ def test_script_nodebug(self):
'eggs',
'--nodebug',
'--client',
'--host', 'localhost',
'--port', '8888',
'spam.py',
])

self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam.py',
'address': Address.as_client(None, 8888),
'address': Address.as_client('localhost', 8888),
'nodebug': True,
'single_session': False,
'wait': False,
Expand Down Expand Up @@ -179,6 +173,7 @@ def test_remote_single_session(self):
args, extra = parse_args([
'eggs',
'--single-session',
'--host', 'localhost',
'--port', '8888',
'spam.py',
])
Expand Down Expand Up @@ -236,6 +231,7 @@ def test_extra(self):
args, extra = parse_args([
'eggs',
'--DEBUG',
'--host', 'localhost',
'--port', '8888',
'--vm_type', '???',
'spam.py',
Expand All @@ -251,7 +247,7 @@ def test_extra(self):
self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam.py',
'address': Address.as_server(None, 8888),
'address': Address.as_server('localhost', 8888),
'nodebug': False,
'single_session': False,
'wait': False,
Expand All @@ -274,6 +270,7 @@ def test_extra_nodebug(self):
'--DEBUG',
'--nodebug',
'--client',
'--host', 'localhost',
'--port', '8888',
'--vm_type', '???',
'spam.py',
Expand All @@ -289,7 +286,7 @@ def test_extra_nodebug(self):
self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam.py',
'address': Address.as_client(None, 8888),
'address': Address.as_client('localhost', 8888),
'nodebug': True,
'single_session': False,
'wait': False,
Expand Down Expand Up @@ -337,6 +334,7 @@ def test_unsupported_arg(self):
def test_pseudo_backward_compatibility(self):
args, extra = parse_args([
'eggs',
'--host', 'localhost',
'--port', '8888',
'--module',
'--file', 'spam',
Expand All @@ -345,7 +343,7 @@ def test_pseudo_backward_compatibility(self):
self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam',
'address': Address.as_server(None, 8888),
'address': Address.as_server('localhost', 8888),
'nodebug': False,
'single_session': False,
'wait': False,
Expand All @@ -357,6 +355,7 @@ def test_pseudo_backward_compatibility_nodebug(self):
'eggs',
'--nodebug',
'--client',
'--host', 'localhost',
'--port', '8888',
'--module',
'--file', 'spam',
Expand All @@ -365,7 +364,7 @@ def test_pseudo_backward_compatibility_nodebug(self):
self.assertEqual(vars(args), {
'kind': 'script',
'name': 'spam',
'address': Address.as_client(None, 8888),
'address': Address.as_client('localhost', 8888),
'nodebug': True,
'single_session': False,
'wait': False,
Expand Down
1 change: 1 addition & 0 deletions tests/system_tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def connect(addr, wait=None, closeonly=False):
proc = Proc.start_python_module('ptvsd', [
'--server',
'--wait',
'--host', 'localhost',
'--port', '5678',
'--file', filename,
], env={
Expand Down

0 comments on commit bd220d0

Please sign in to comment.