Exemple #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)
Exemple #2
0
    def start(session, multiprocess=False):
        if multiprocess:
            pytest.skip("https://github.com/microsoft/ptvsd/issues/1706")

        # 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 platform.system() != "Windows":
            locale = "en_US.utf8" if platform.system(
            ) == "Linux" else "en_US.UTF-8"
            session.config.env.update({"LC_ALL": locale, "LANG": locale})

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

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

        return run(session,
                   targets.Module(name="flask", args=args),
                   cwd=paths.flask1)
Exemple #3
0
def test_run_submodule(run):
    with debug.Session() as session:
        session.config["cwd"] = test_data / "testpkgs"

        backchannel = session.open_backchannel()
        with run(session, targets.Module(name="pkg1.sub")):
            pass

        assert backchannel.receive() == "ok"
Exemple #4
0
def test_breakpoint_in_package_main(run):
    testpkgs = test_data / "testpkgs"
    main_py = testpkgs / "pkg1" / "__main__.py"

    with debug.Session() as session:
        session.expected_exit_code = 42
        session.config["cwd"] = testpkgs.strpath

        with run(session, targets.Module(name="pkg1")):
            session.set_breakpoints(main_py, ["two"])

        session.wait_for_stop(
            "breakpoint",
            expected_frames=[some.dap.frame(main_py, line="two")])
        session.request_continue()