# Path: acpype/cli.py
# def _chk_py_ver():
# def _handle_exception(level):
# def init_main(binaries: Dict[str, str] = binaries, argv: Optional[List[str]] = None):
# 
# Path: acpype/utils.py
# def _getoutput(cmd):
#     """
#     To simulate commands.getoutput
#     shell=True is necessary despite security issues
#     """
#     out = sub.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0][:-1]
#     return out.decode()


import pytest
from acpype import cli
from acpype.utils import _getoutput
    assert msg1 in captured.out
    assert msg2 in captured.out
    assert msg3 in captured.out
    _getoutput(f"rm -vfr {temp_base}* .*{temp_base}*")


@pytest.mark.parametrize(
    ("inp", "msg"),
    [
        ("AAA.pdb", "ERROR: no 'no_obabel' executable; you need it if input is PDB or SMILES"),
        ("cccc", "WARNING: your input may be a SMILES but"),
    ],
)
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_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

# Path: acpype/cli.py
# def _chk_py_ver():
# def _handle_exception(level):
# def init_main(binaries: Dict[str, str] = binaries, argv: Optional[List[str]] = None):
# 
# Path: acpype/utils.py
# def _getoutput(cmd):
#     """
#     To simulate commands.getoutput
#     shell=True is necessary despite security issues
#     """
#     out = sub.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0][:-1]
#     return out.decode()


# Path: tests/test_scenarios.py
import pytest
from acpype import cli
from acpype.utils import _getoutput

    assert msg1 in captured.out
    assert msg2 in captured.out
    assert msg3 in captured.out
    _getoutput(f"rm -vfr {temp_base}* .*{temp_base}*")


@pytest.mark.parametrize(
    ("inp", "msg"),
    [
        ("AAA.pdb", "ERROR: no 'no_obabel' executable; you need it if input is PDB or SMILES"),
        ("cccc", "WARNING: your input may be a SMILES but"),
    ],
)
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_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}*")