Esempio n. 1
0
    def start(session, multiprocess=False):
        # No clean way to kill Flask server, expect non-zero exit code
        session.expected_exit_code = some.int

        session.config.env.update(
            {
                "FLASK_APP": paths.app_py,
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "1" if multiprocess else "0",
            }
        )
        if sys.platform != "win32":
            locale = "en_US.utf8" if sys.platform.startswith("linux") else "en_US.UTF-8"
            session.config.env.update({"LC_ALL": locale, "LANG": locale})

        session.config.update({"jinja": True, "subProcess": multiprocess})

        args = ["run", "--no-debugger", "--with-threads"]
        if multiprocess:
            args += ["--reload"]
        else:
            args += ["--no-reload"]
        args += ["--port", str(flask_server.port)]

        if multiprocess and run.request == "attach":
            # 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.Program(paths.main_py, args=args)
        else:
            target = targets.Module(name="flask", args=args)

        return run(session, target, cwd=paths.flask1)
Esempio n. 2
0
    def start(session, multiprocess=False):
        # No clean way to kill Django server, expect non-zero exit code
        session.expected_exit_code = some.int

        session.config.update({"django": True, "subProcess": bool(multiprocess)})

        args = ["runserver"]
        if not multiprocess:
            args += ["--noreload"]
        args += ["--", str(django_server.port)]

        return run(session, targets.Program(paths.app_py, args=args), cwd=paths.django1)
Esempio n. 3
0
    def start(session, multiprocess=False):
        if multiprocess:
            pytest.skip("https://github.com/microsoft/ptvsd/issues/1706")

        # No clean way to kill Django server, expect non-zero exit code
        session.expected_exit_code = some.int

        session.config.update({"django": True, "subProcess": bool(multiprocess)})

        args = ["runserver"]
        if not multiprocess:
            args += ["--noreload"]
        args += ["--", str(django_server.port)]

        return run(session, targets.Program(paths.app_py, args=args), cwd=paths.django1)
Esempio n. 4
0
def test_run_relative_path(pyfile, run):
    @pyfile
    def code_to_debug():
        import debuggee
        from debuggee import backchannel
        from _pydev_bundle.pydev_log import list_log_files

        debuggee.setup()
        from _pydevd_bundle import pydevd_constants  # @ bp1

        backchannel.send(
            list_log_files(pydevd_constants.DebugInfoHolder.PYDEVD_DEBUG_FILE)
        )
        assert backchannel.receive() == "continue"

    with debug.Session() as session:
        backchannel = session.open_backchannel()
        code_to_debug = str(code_to_debug)
        cwd = os.path.dirname(os.path.dirname(code_to_debug))

        program = targets.Program(code_to_debug)
        program.make_relative(cwd)
        with run(session, program):
            session.set_breakpoints(code_to_debug, all)

        session.wait_for_stop()
        session.request_continue()

        pydevd_debug_files = backchannel.receive()
        backchannel.send("continue")
        session.wait_for_next_event("terminated")
        session.proceed()

    # Check if we don't have errors in the pydevd log (the
    # particular error this test is covering:
    # https://github.com/microsoft/debugpy/issues/620
    # is handled by pydevd but produces a Traceback in the logs).
    for pydevd_debug_file in pydevd_debug_files:
        with open(pydevd_debug_file, "r") as stream:
            contents = stream.read()

    assert "critical" not in contents
    assert "Traceback" not in contents