How to use the watchgod.cli.cli function in watchgod

To help you get started, we’ve selected a few watchgod 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 samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_simple(mocker, tmpdir):
    mocker.patch('watchgod.cli.set_start_method')
    mocker.patch('watchgod.cli.sys.stdin.fileno')
    mocker.patch('os.ttyname', return_value='/path/to/tty')
    mock_run_process = mocker.patch('watchgod.cli.run_process')
    cli('tests.test_cli.foobar', str(tmpdir))
    mock_run_process.assert_called_once_with(
        Path(str(tmpdir)),
        run_function,
        args=('tests.test_cli.foobar', '/path/to/tty'),
        callback=callback
    )
github samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_invalid_import1(mocker, tmpdir, capsys):
    sys_exit = mocker.patch('watchgod.cli.sys.exit')
    cli('foobar')
    sys_exit.assert_called_once_with(1)
    out, err = capsys.readouterr()
    assert out == ''
    assert err == 'ImportError: "foobar" doesn\'t look like a module path\n'
github samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_tty_os_error(mocker, tmpworkdir):
    mocker.patch('watchgod.cli.set_start_method')
    mocker.patch('watchgod.cli.sys.stdin.fileno', side_effect=OSError)
    mock_run_process = mocker.patch('watchgod.cli.run_process')
    cli('tests.test_cli.foobar')
    mock_run_process.assert_called_once_with(
        Path(str(tmpworkdir)),
        run_function,
        args=('tests.test_cli.foobar', '/dev/tty'),
        callback=callback
    )
github samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_tty_attribute_error(mocker, tmpdir):
    mocker.patch('watchgod.cli.set_start_method')
    mocker.patch('watchgod.cli.sys.stdin.fileno', side_effect=AttributeError)
    mock_run_process = mocker.patch('watchgod.cli.run_process')
    cli('tests.test_cli.foobar', str(tmpdir))
    mock_run_process.assert_called_once_with(
        Path(str(tmpdir)),
        run_function,
        args=('tests.test_cli.foobar', None),
        callback=callback
    )
github samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_invalid_import2(mocker, tmpdir, capsys):
    sys_exit = mocker.patch('watchgod.cli.sys.exit')
    cli('pprint.foobar')
    sys_exit.assert_called_once_with(1)
    out, err = capsys.readouterr()
    assert out == ''
    assert err == 'ImportError: Module "pprint" does not define a "foobar" attribute\n'
github samuelcolvin / watchgod / tests / test_cli.py View on Github external
def test_invalid_path(mocker, capsys):
    sys_exit = mocker.patch('watchgod.cli.sys.exit')
    cli('tests.test_cli.foobar', '/does/not/exist')
    sys_exit.assert_called_once_with(1)
    out, err = capsys.readouterr()
    assert out == ''
    assert err == 'path "/does/not/exist" is not a directory\n'