Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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]
Ejemplo n.º 4
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})
Ejemplo n.º 5
0
 def test_defaults(self):
     """
     Legacy defaults are translated into default_value attributes.
     """
     l = _ensure_attributes(["a"], {"a": 42})
     assert 42 == l[0].default_value
Ejemplo n.º 6
0
 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]
Ejemplo n.º 7
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})
Ejemplo n.º 8
0
 def test_defaults(self):
     """
     Legacy defaults are translated into default_value attributes.
     """
     l = _ensure_attributes(["a"], {"a": 42})
     assert 42 == l[0].default_value