예제 #1
0
파일: test_utils.py 프로젝트: zuik/dagster
def test_execute_file(tmp_file):
    with tmp_file("ls") as (tmp_path, tmp_file):
        res, retcode = execute_script_file(
            tmp_file, output_logging="BUFFER", log=logging, cwd=tmp_path
        )
        assert os.path.basename(tmp_file) in res
        assert retcode == 0
예제 #2
0
def test_execute_file_large_line_stream_output(tmp_file):
    large_string = "0123456789" * (100000)  # one giant line > 2**16 buffer
    with tmp_file(f"echo -n {large_string}") as (tmp_path, tmp_file):
        output, retcode = execute_script_file(tmp_file,
                                              output_logging="STREAM",
                                              log=logging,
                                              cwd=tmp_path)
        assert retcode == 0
        assert output == large_string
예제 #3
0
def test_execute_file_large_output_no_logging(tmp_file):
    large_string = "0123456789" * (6600)  # bigger than 2**16 buffer
    with tmp_file(f"echo -n {large_string}") as (tmp_path, tmp_file):
        output, retcode = execute_script_file(tmp_file,
                                              output_logging="NONE",
                                              log=logging,
                                              cwd=tmp_path)
        assert retcode == 0
        assert output == ""
예제 #4
0
파일: test_utils.py 프로젝트: zuik/dagster
def test_env(tmp_file):
    cmd = "echo $TEST_VAR"
    res, retcode = execute(
        cmd, output_logging="BUFFER", log=logging, env={"TEST_VAR": "some_env_value"}
    )
    assert res.strip() == "some_env_value"
    assert retcode == 0

    with tmp_file(cmd) as (_, tmp_file):
        res, retcode = execute_script_file(
            tmp_file,
            output_logging="BUFFER",
            log=logging,
            env={"TEST_VAR": "some_env_value"},
        )
        assert res.strip() == "some_env_value"
        assert retcode == 0
예제 #5
0
def test_env(tmp_file):
    cmd = 'echo $TEST_VAR'
    res, retcode = execute(cmd,
                           output_logging='BUFFER',
                           log=logging,
                           env={'TEST_VAR': 'some_env_value'})
    assert res.strip() == 'some_env_value'
    assert retcode == 0

    with tmp_file(cmd) as (_, tmp_file):
        res, retcode = execute_script_file(
            tmp_file,
            output_logging='BUFFER',
            log=logging,
            env={'TEST_VAR': 'some_env_value'},
        )
        assert res.strip() == 'some_env_value'
        assert retcode == 0