From b862bb314357ed48ddd97e642bc66510d7c12567 Mon Sep 17 00:00:00 2001 From: Pavel Minaev Date: Wed, 30 Oct 2019 15:37:16 -0700 Subject: [PATCH] Disable attach_by_socket("api") for test_flask due to #1886 --- tests/ptvsd/server/test_flask.py | 22 ++++++++++++++-------- tests/test_data/flask1/main.py | 8 ++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 tests/test_data/flask1/main.py diff --git a/tests/ptvsd/server/test_flask.py b/tests/ptvsd/server/test_flask.py index bab2b497..9cc1ad5d 100644 --- a/tests/ptvsd/server/test_flask.py +++ b/tests/ptvsd/server/test_flask.py @@ -9,7 +9,7 @@ import pytest from ptvsd.common import compat from tests import code, debug, log, net, test_data -from tests.debug import targets +from tests.debug import runners, targets from tests.patterns import some pytestmark = pytest.mark.timeout(60) @@ -20,6 +20,7 @@ flask_server = net.WebServer(net.get_test_server_port(7000, 7100)) class paths: flask1 = test_data / "flask1" app_py = flask1 / "app.py" + main_py = flask1 / "main.py" hello_html = flask1 / "templates" / "hello.html" bad_html = flask1 / "templates" / "bad.html" @@ -28,6 +29,17 @@ class lines: app_py = code.get_marked_line_numbers(paths.app_py) +@pytest.fixture( + params=[ + runners.launch["internalConsole"], + runners.launch["integratedTerminal"], + runners.attach_by_socket["cli"], + ] +) +def run(request): + return request.param + + @pytest.fixture def start_flask(run): def start(session, multiprocess=False): @@ -58,13 +70,7 @@ def start_flask(run): # For multiproc attach, we need to use a helper stub to import debug_me # before running Flask; otherwise, we will get the connection only from # the subprocess, not from the Flask server process. - target = targets.Code( - code=( - "import debug_me, runpy;" - "runpy.run_module('flask', run_name='__main__')" - ), - args=args, - ) + target = targets.Program(paths.main_py, args=args) else: target = targets.Module(name="flask", args=args) diff --git a/tests/test_data/flask1/main.py b/tests/test_data/flask1/main.py new file mode 100644 index 00000000..c14c129b --- /dev/null +++ b/tests/test_data/flask1/main.py @@ -0,0 +1,8 @@ +# For multiproc attach, we need to use a helper stub to import debug_me before running +# Flask; otherwise, we will get the connection only from the subprocess, not from the +# Flask server process. + +import debug_me # noqa +import runpy + +runpy.run_module("flask", run_name="__main__")