def test_fail_existing_file(mocker): mocker.patch("os.path.isfile", return_value=False) with pytest.raises(argparse.ArgumentTypeError, match="No file called"): parser.existing_file("any")
def test_existing_file(mocker): mocker.patch("os.path.isfile", return_value=True) assert os.path.abspath("any") == parser.existing_file("any")