Skip to content

Commit

Permalink
Swap attach_listen / attach_connect to reflect the client perspective.
Browse files Browse the repository at this point in the history
  • Loading branch information
int19h committed Mar 5, 2020
1 parent 73a4c8b commit 2d013e5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
20 changes: 10 additions & 10 deletions tests/debug/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ def attach_pid(session, target, cwd=None, wait=True):


@_runner
def attach_listen(session, target, method, cwd=None, wait=True, log_dir=None):
def attach_connect(session, target, method, cwd=None, wait=True, log_dir=None):
log.info(
"Attaching {0} to {1} by socket using {2}.", session, target, method.upper()
)

assert method in ("api", "cli")

config = _attach_common_config(session, target, cwd)
config["host"] = host = attach_listen.host
config["port"] = port = attach_listen.port
config["host"] = host = attach_connect.host
config["port"] = port = attach_connect.port

if method == "cli":
args = [
Expand Down Expand Up @@ -254,12 +254,12 @@ def attach_listen(session, target, method, cwd=None, wait=True, log_dir=None):
return session.request_attach()


attach_listen.host = "127.0.0.1"
attach_listen.port = net.get_test_server_port(5678, 5800)
attach_connect.host = "127.0.0.1"
attach_connect.port = net.get_test_server_port(5678, 5800)


@_runner
def attach_connect(session, target, method, cwd=None, log_dir=None):
def attach_listen(session, target, method, cwd=None, log_dir=None):
log.info(
"Attaching {0} to {1} by socket using {2}.", session, target, method.upper()
)
Expand All @@ -268,8 +268,8 @@ def attach_connect(session, target, method, cwd=None, log_dir=None):

config = _attach_common_config(session, target, cwd)
config["listen"] = True
config["host"] = host = attach_connect.host
config["port"] = port = attach_connect.port
config["host"] = host = attach_listen.host
config["port"] = port = attach_listen.port

if method == "cli":
args = [
Expand Down Expand Up @@ -302,8 +302,8 @@ def spawn_debuggee(occ):
return session.request_attach()


attach_connect.host = "127.0.0.1"
attach_connect.port = net.get_test_server_port(5678, 5800)
attach_listen.host = "127.0.0.1"
attach_listen.port = net.get_test_server_port(5478, 5600)


all_launch = [
Expand Down
2 changes: 1 addition & 1 deletion tests/debugpy/test_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def code_to_debug():
session.request_continue()


@pytest.mark.parametrize("run", runners.all_attach_listen)
@pytest.mark.parametrize("run", runners.all_attach_connect)
def test_reattach(pyfile, target, run):
@pyfile
def code_to_debug():
Expand Down
2 changes: 1 addition & 1 deletion tests/debugpy/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class lines:


@pytest.fixture
@pytest.mark.parametrize("run", [runners.launch, runners.attach_listen["cli"]])
@pytest.mark.parametrize("run", [runners.launch, runners.attach_connect["cli"]])
def start_django(run):
def start(session, multiprocess=False):
# No clean way to kill Django server, expect non-zero exit code
Expand Down
2 changes: 2 additions & 0 deletions tests/debugpy/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import sys

from tests import debug
from tests.debug import runners


@pytest.mark.parametrize("case", ["match_case", "mismatch_case"])
@pytest.mark.parametrize("run", runners.all_launch)
def test_env_replace_var(pyfile, target, run, case):
@pyfile
def code_to_debug():
Expand Down
2 changes: 1 addition & 1 deletion tests/debugpy/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class lines:


@pytest.fixture
@pytest.mark.parametrize("run", [runners.launch, runners.attach_listen["cli"]])
@pytest.mark.parametrize("run", [runners.launch, runners.attach_connect["cli"]])
def start_flask(run):
def start(session, multiprocess=False):
# No clean way to kill Flask server, expect non-zero exit code
Expand Down
2 changes: 1 addition & 1 deletion tests/debugpy/test_source_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


if not tests.full:
@pytest.fixture(params=[runners.launch, runners.attach_listen["api"]])
@pytest.fixture(params=[runners.launch, runners.attach_connect["cli"]])
def run(request):
return request.param

Expand Down

0 comments on commit 2d013e5

Please sign in to comment.