def test_hasattrs_basic(): """ hasattrs.py: Basic usage """ a = AttrObj() assert hasattrs(a, 'a', 'b', 'c') assert hasattrs(a, 'a') assert hasattrs(a, 'b', 'd') assert not hasattrs(a, 'e')
def validate(opts): """ Client facing overwrite validation. Checks to see if the opts arguments contains the attributes 'overwrite', 'input', and 'output'. :param opts: a namespace containing the attributes 'overwrite', 'input', and 'output' :raises ValueError: if the value passed in is not a namespace with the attributes 'overwrite', 'input', and 'output' :raises ValidationException: if opts fails any of the validations :return: True if opts passes the validations """ if hasattrs(opts, 'overwrite', 'input', 'output'): return _validate(opts) else: raise ValueError("opts object must have attributes 'overwrite', " "'input', and 'output.")
def test_hasattrs_no_names(): """ hasattrs.py: Provide no attribute names """ a = AttrObj() assert hasattrs(a)