Пример #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
Пример #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
Пример #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]
Пример #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})
Пример #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
Пример #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]
Пример #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})
Пример #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