def test_str2bool(): for val in ['true', 'y', 'yes']: assert str2bool(val) assert str2bool(val.upper()) for val in ['false', 'n', 'no']: assert not str2bool(val) assert not str2bool(val.upper())
def test_str2bool_exception_empty_str(): with pytest.raises(argparse.ArgumentTypeError): str2bool('')
def test_str2bool_bool(): assert str2bool(True) assert not str2bool(False)
def test_str2bool_exception(): with pytest.raises(argparse.ArgumentTypeError): str2bool('foo')