def test_converts_rest(self): """ Any other item will be transformed into an Attribute. """ l = _ensure_attributes(["a"]) assert isinstance(l[0], Attribute) assert "a" == l[0].name
def test_converts_rest(self): """ Any other item will be transformed into an Attribute. """ l = _ensure_attributes(["a"], {}) assert isinstance(l[0], Attribute) assert "a" == l[0].name
def test_leaves_attribute_alone(self): """ List items that are an Attribute stay an Attribute. """ a = Attribute("a") assert a is _ensure_attributes([a])[0]
def test_defaults_Attribute(self): """ Raises ValueError on defaults != {} and an Attribute within attrs. """ with pytest.raises(ValueError): _ensure_attributes([Attribute("a")], defaults={"a": 42})
def test_defaults(self): """ Legacy defaults are translated into default_value attributes. """ l = _ensure_attributes(["a"], {"a": 42}) assert 42 == l[0].default_value
def test_leaves_attribute_alone(self): """ List items that are an Attribute stay an Attribute. """ a = Attribute("a") assert a is _ensure_attributes([a], {})[0]