def test_amb2gmx_no_bins(janitor, capsys): binaries = {"ac_bin": "no_ac", "obabel_bin": "no_obabel"} argv = ["-x", "Base.inpcrd", "-p", "Base.prmtop"] temp_base = "vir_temp" cli.init_main(argv=argv + ["-b", temp_base], binaries=binaries) captured = capsys.readouterr() assert "Total time of execution:" in captured.out _getoutput(f"rm -vfr {temp_base}* .*{temp_base}*")
def test_args_wrong_inputs(janitor, capsys, argv, code, msg): with pytest.raises(SystemExit) as e_info: init_main(argv=argv) captured = capsys.readouterr() assert msg in captured.err + captured.out assert e_info.typename == "SystemExit" assert e_info.value.code == code _getoutput("rm -vfr vir_temp* .*vir_temp*")
def test_no_obabel(janitor, capsys, inp, msg): binaries = {"ac_bin": "antechamber", "obabel_bin": "no_obabel"} with pytest.raises(SystemExit) as e_info: cli.init_main(argv=["-di", inp, "-c", "gas"], binaries=binaries) captured = capsys.readouterr() assert msg in captured.out assert e_info.typename == "SystemExit" assert e_info.value.code == 19
def test_no_ac(janitor, capsys): binaries = {"ac_bin": "no_ac", "obabel_bin": "obabel"} msg = f"ERROR: no '{binaries['ac_bin']}' executable... aborting!" inp = "AAA.mol2" with pytest.raises(SystemExit) as e_info: cli.init_main(argv=["-di", inp, "-c", "gas"], binaries=binaries) captured = capsys.readouterr() assert msg in captured.out assert e_info.typename == "SystemExit" assert e_info.value.code == 19
def test_only_ac(janitor, capsys): binaries = {"ac_bin": "antechamber", "obabel_bin": "no_obabel"} msg1 = f"WARNING: no '{binaries['obabel_bin']}' executable, no PDB file can be used as input!" msg2 = "Total time of execution:" msg3 = "WARNING: No Openbabel python module, no chiral groups" inp = "AAA.mol2" temp_base = "vir_temp" cli.init_main(argv=["-di", inp, "-c", "gas", "-b", temp_base], binaries=binaries) captured = capsys.readouterr() assert msg1 in captured.out assert msg2 in captured.out assert msg3 in captured.out _getoutput(f"rm -vfr {temp_base}* .*{temp_base}*")
def test_inputs(janitor, capsys, argv, msg): temp_base = "vir_temp" init_main(argv=argv) captured = capsys.readouterr() assert msg in captured.out _getoutput(f"rm -vfr {temp_base}* .*{temp_base}* smiles_molecule.acpype")
#!/usr/bin/env python3 import re import sys from acpype.cli import init_main if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0]) sys.exit(init_main())