コード例 #1
0
def test_run_error():
    with pytest.raises(_errors.ExecuteUserScriptError) as e:
        _modules.run('wrong module')

    message = str(e.value)
    assert 'ExecuteUserScriptError:' in message
    assert ' No module named wrong module' in message
コード例 #2
0
def test_run_no_wait(log_script_invocation,  create, executable):
    _modules.run('pytest', ['--version'], {'PYPATH': '/opt/ml/code'}, wait=False, capture_error=True)

    expected_cmd = [executable(), '-m', 'pytest', '--version']
    log_script_invocation.assert_called_with(expected_cmd, {'PYPATH': '/opt/ml/code'})
    create.assert_called_with(expected_cmd, _errors.ExecuteUserScriptError,
                              capture_error=True)
コード例 #3
0
def test_run(log_script_invocation,  check_error, executable):
    _modules.run('pytest', ['--version'])

    expected_cmd = [executable(), '-m', 'pytest', '--version']
    log_script_invocation.assert_called_with(expected_cmd, {})
    check_error.assert_called_with(expected_cmd, _errors.ExecuteUserScriptError,
                                   capture_error=False)
コード例 #4
0
def test_run(log_script_invocation, check_error, executable):
    _modules.run("pytest", ["--version"])

    expected_cmd = [executable(), "-m", "pytest", "--version"]
    log_script_invocation.assert_called_with(expected_cmd, {})
    check_error.assert_called_with(expected_cmd,
                                   _errors.ExecuteUserScriptError,
                                   capture_error=False)
コード例 #5
0
def test_run_error(capture_error):
    with pytest.raises(_errors.ExecuteUserScriptError) as e:
        _modules.run("wrong module", capture_error=capture_error)

    message = str(e.value)
    assert "ExecuteUserScriptError:" in message
    if capture_error:
        assert " No module named wrong module" in message
コード例 #6
0
def test_run_no_wait(log_script_invocation, create, executable):
    _modules.run(
        "pytest", ["--version"], {"PYPATH": "/opt/ml/code"}, wait=False, capture_error=True
    )

    expected_cmd = [executable(), "-m", "pytest", "--version"]
    log_script_invocation.assert_called_with(expected_cmd, {"PYPATH": "/opt/ml/code"})
    create.assert_called_with(expected_cmd, _errors.ExecuteUserScriptError, capture_error=True)
コード例 #7
0
def test_run():
    _modules.run('pytest', ['--version'])