コード例 #1
0
def test_dir_to_csv_different_dir_path(tmp_path, sas7bdat_dir):
    converter.dir_to_csv(dir_path=sas7bdat_dir, export_path=tmp_path)
    sas_counter = len([
        name for name in sas7bdat_dir.iterdir() if name.suffix == ".sas7bdat"
    ])
    convert_counter = len(
        [name for name in tmp_path.iterdir() if name.suffix == ".csv"])

    assert sas_counter == convert_counter
コード例 #2
0
def test_dir_to_csv_different_dir(tmpdir, sas7bdat_dir):
    converter.dir_to_csv(dir_path=str(sas7bdat_dir), export_path=str(tmpdir))
    sas_counter = len([
        name for name in Path(sas7bdat_dir).iterdir()
        if name.suffix == 'sas7bdat'
    ])
    convert_counter = len(
        [name for name in Path(tmpdir).iterdir() if name.suffix == 'csv'])

    assert sas_counter == convert_counter
コード例 #3
0
def test_dir_to_csv_no_continue(tmp_path, sas7bdat_dir, bad_sas_file):
    sas_files = [str(x) for x in sas7bdat_dir.iterdir()]
    for sas_file in sas_files:
        shutil.copy(sas_file, str(tmp_path))

    shutil.copy(bad_sas_file, str(tmp_path))
    with pytest.raises(Exception) as execinfo:
        converter.dir_to_csv(tmp_path, continue_on_error=False)

    assert execinfo.value
コード例 #4
0
def test_dir_to_csv_same_dir(tmpdir, sas7bdat_dir):
    sas_files = [str(x) for x in sas7bdat_dir.iterdir()]
    for sas_file in sas_files:
        shutil.copy(sas_file, tmpdir)

    converter.dir_to_csv(str(tmpdir))
    sas_counter = len(
        [name for name in Path(tmpdir).iterdir() if name.suffix == 'sas7bdat'])
    convert_counter = len(
        [name for name in Path(tmpdir).iterdir() if name.suffix == 'csv'])

    assert sas_counter == convert_counter
コード例 #5
0
def test_dir_to_csv_same_dir_path(tmp_path, sas7bdat_dir):
    sas_files = [str(x) for x in sas7bdat_dir.iterdir()]
    for sas_file in sas_files:
        shutil.copy(sas_file, str(tmp_path))

    converter.dir_to_csv(tmp_path)
    sas_counter = len(
        [name for name in tmp_path.iterdir() if name.suffix == ".sas7bdat"])
    convert_counter = len(
        [name for name in tmp_path.iterdir() if name.suffix == ".csv"])

    assert sas_counter == convert_counter
コード例 #6
0
def test_dir_to_csv_continue(tmp_path, caplog, sas7bdat_dir, bad_sas_file):
    sas_files = [str(x) for x in sas7bdat_dir.iterdir()]
    for sas_file in sas_files:
        shutil.copy(sas_file, str(tmp_path))

    shutil.copy(bad_sas_file, str(tmp_path))

    converter.dir_to_csv(tmp_path, continue_on_error=True)
    sas_counter = len(
        [name
         for name in tmp_path.iterdir() if name.suffix == ".sas7bdat"]) - 1
    convert_counter = len(
        [name for name in tmp_path.iterdir() if name.suffix == ".csv"])

    assert sas_counter == convert_counter
    assert "Error converting" in caplog.text