Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
)
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
)
def test_run_function(tmpworkdir):
assert not tmpworkdir.join('sentinel').exists()
run_function('tests.test_cli.foobar', None)
assert tmpworkdir.join('sentinel').exists()
def test_run_function_tty(tmpworkdir):
# could this cause problems by changing sys.stdin?
assert not tmpworkdir.join('sentinel').exists()
run_function('tests.test_cli.foobar', '/dev/tty')
assert tmpworkdir.join('sentinel').exists()