def test_dir_to_xml_different_dir_path(tmp_path, sas7bdat_dir): converter.dir_to_xml(sas7bdat_dir, 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 == ".xml"]) assert sas_counter == convert_counter
def test_dir_to_xml_different_dir(tmpdir, sas7bdat_dir): converter.dir_to_xml(str(sas7bdat_dir), 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 == 'xml']) assert sas_counter == convert_counter
def test_dir_to_xml_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_xml(tmp_path, continue_on_error=False) assert execinfo.value
def test_dir_to_xml_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_xml(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 == 'xml']) assert sas_counter == convert_counter
def test_dir_to_xml_same_dir_path(tmp_path, sas7bdat_dir): sas_files = [x for x in sas7bdat_dir.iterdir()] for sas_file in sas_files: shutil.copy(sas_file, str(tmp_path)) converter.dir_to_xml(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 == ".xml"]) assert sas_counter == convert_counter
def test_dir_to_xml_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_xml(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 == ".xml"]) assert sas_counter == convert_counter assert "Error converting" in caplog.text