How to use the blackhole.application.run function in blackhole

To help you get started, we’ve selected a few blackhole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kura / blackhole / tests / test_application.py View on Github external
def test_run_test():
    cfile = create_config(("",))
    with mock.patch("sys.argv", ["blackhole", "-t", "-c", cfile]), mock.patch(
        "blackhole.config.Config.test_port", return_value=True
    ), mock.patch(
        "blackhole.config.Config.test_pidfile", return_value=True
    ), pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 0
github kura / blackhole / tests / test_application.py View on Github external
def test_run_load_test_fails():
    cfile = create_config(("listen=127.0.0.1:0",))
    with mock.patch("sys.argv", ["blackhole", "-t", "-c", cfile]), mock.patch(
        "blackhole.config.Config.test", side_effect=ConfigException()
    ), pytest.raises(SystemExit) as exc:
        run()
    assert exc.value.code == 64
github kura / blackhole / tests / test_application.py View on Github external
)
    c = Config(cfile).load()

    with mock.patch("sys.argv", ["-c {}".format(cfile)]), mock.patch(
        "blackhole.config.Config.test", return_value=c
    ), mock.patch("blackhole.config.warn_options"), mock.patch(
        "atexit.register"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.close_socks"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.generate_servers",
        side_effect=BlackholeRuntimeException,
    ), pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 77
github kura / blackhole / tests / test_application.py View on Github external
), mock.patch(
        "blackhole.supervisor.Supervisor.generate_servers"
    ), mock.patch(
        "blackhole.daemon.Daemon.daemonize"
    ), mock.patch(
        "blackhole.control.pid_permissions"
    ), mock.patch(
        "blackhole.control.setgid"
    ), mock.patch(
        "blackhole.control.setuid"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.run"
    ), pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 0
github kura / blackhole / tests / test_application.py View on Github external
pidfile = os.path.join(os.getcwd(), "blackhole-test.pid")
    cfile = create_config(
        ("listen=127.0.0.1:9000", "pidfile={}".format(pidfile))
    )
    c = Config(cfile).load()

    with mock.patch("sys.argv", ["-c {}".format(cfile)]), mock.patch(
        "blackhole.config.Config.test", return_value=c
    ), mock.patch("blackhole.config.warn_options"), mock.patch(
        "os.getpid", return_value=1234
    ), mock.patch(
        "atexit.register", side_effect=DaemonException
    ), pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 64
github kura / blackhole / tests / test_application.py View on Github external
with mock.patch("sys.argv", ["-c {}".format(cfile), "-b"]), mock.patch(
        "blackhole.application.Config.test", return_value=c
    ), mock.patch("blackhole.config.warn_options"), mock.patch(
        "atexit.register"
    ), mock.patch(
        "os.chown"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.generate_servers"
    ), mock.patch(
        "os.fork", side_effect=OSError
    ), mock.patch(
        "blackhole.supervisor.Supervisor." "close_socks"
    ) as mock_close, pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 77
    assert mock_close.called is True
github kura / blackhole / tests / test_application.py View on Github external
), mock.patch(
        "os.chown"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.generate_servers"
    ), mock.patch(
        "blackhole.control.pid_permissions"
    ), mock.patch(
        "blackhole.control.setgid"
    ), mock.patch(
        "blackhole.control.setuid"
    ), mock.patch(
        "blackhole.supervisor.Supervisor.run"
    ), pytest.raises(
        SystemExit
    ) as exc:
        run()
    assert exc.value.code == 0
github kura / blackhole / tests / test_application.py View on Github external
def test_run_test_fails():
    cfile = create_config(("listen=127.0.0.1:0",))
    with mock.patch(
        "sys.argv", ["blackhole", "-t", "-c", cfile]
    ), pytest.raises(SystemExit) as exc:
        run()
    assert exc.value.code == 64