Example #1
0
def attribute(name: str, value: str = None):
    if value:
        warnings.warn(
            'passing second argument is deprecated; use have.attribute(foo).value(bar) instead',
            DeprecationWarning,
        )
        return _match.element_has_attribute(name).value(value).not_

    original = _match.element_has_attribute(name)
    negated = original.not_

    def value(self, expected: str, ignore_case=False) -> Condition[Element]:
        return original.value(expected, ignore_case).not_

    def value_containing(self,
                         expected: str,
                         ignore_case=False) -> Condition[Element]:
        return original.value_containing(expected, ignore_case).not_

    def values(self, *expected: str) -> Condition[Collection]:
        return original.values(*expected).not_

    def values_containing(self, *expected: str) -> Condition[Collection]:
        return original.values_containing(*expected).not_

    negated.value = value
    negated.value_containing = value_containing
    negated.values = values
    negated.values_containing = values_containing

    return negated
Example #2
0
def attribute(name: str, value: str = None):
    if value:
        warnings.warn(
            'passing second argument is deprecated; use have.attribute(foo).value(bar) instead',
            DeprecationWarning)
        return match.element_has_attribute(name).value(value)

    return match.element_has_attribute(name)