Exemplo n.º 1
0
def test_quote_string():
    my_str = "Hello World"
    assert cu.quote_string(my_str) == '"' + my_str + '"'

    my_str = "'Hello World'"
    assert cu.quote_string(my_str) == '"' + my_str + '"'

    my_str = '"Hello World"'
    assert cu.quote_string(my_str) == "'" + my_str + "'"
Exemplo n.º 2
0
def test_run_pyscript_with_odd_file_names(base_app, python_script):
    """
    Pass in file names with various patterns. Since these files don't exist, we will rely
    on the error text to make sure the file names were processed correctly.
    """
    # Mock input to get us passed the warning about not ending in .py
    input_mock = mock.MagicMock(name='input', return_value='1')
    builtins.input = input_mock

    out, err = run_cmd(
        base_app, "run_pyscript {}".format(utils.quote_string(python_script)))
    err = ''.join(err)
    assert "Error reading script file '{}'".format(python_script) in err
Exemplo n.º 3
0
def test_run_pyscript_with_odd_file_names(base_app):
    """
    Pass in file names with various patterns. Since these files don't exist, we will rely
    on the error text to make sure the file names were processed correctly.
    """
    python_script = utils.quote_string('nothingweird.py')
    out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
    assert "Error reading script file 'nothingweird.py'" in err[0]

    python_script = utils.quote_string('has   spaces.py')
    out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
    assert "Error reading script file 'has   spaces.py'" in err[0]

    # For remaining tests, mock input to get us passed the warning about not ending in .py
    input_mock = mock.MagicMock(name='input', return_value='1')
    builtins.input = input_mock

    python_script = utils.quote_string('"is_double_quoted.py"')
    out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
    assert "Error reading script file '\"is_double_quoted.py\"'" in err[1]

    python_script = utils.quote_string("'is_single_quoted.py'")
    out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
    assert "Error reading script file ''is_single_quoted.py''" in err[1]