def test_instance(self, C): """ Raises `TypeError` on non-classes. """ with pytest.raises(TypeError) as e: fields_dict(C(1, 2)) assert "Passed object must be a class." == e.value.args[0]
def test_instance(self, C): """ Raises `TypeError` on non-classes. """ with pytest.raises(TypeError) as e: fields_dict(C(1, 2)) assert "Passed object must be a class." == e.value.args[0]
def test_handler_non_attrs_class(self, C): """ Raises `ValueError` if passed a non-``attrs`` instance. """ with pytest.raises(NotAnAttrsClassError) as e: fields_dict(object) assert ("{o!r} is not an attrs-decorated class.".format( o=object)) == e.value.args[0]
def test_handler_non_attrs_class(self, C): """ Raises `ValueError` if passed a non-``attrs`` instance. """ with pytest.raises(NotAnAttrsClassError) as e: fields_dict(object) assert ( "{o!r} is not an attrs-decorated class.".format(o=object) ) == e.value.args[0]
def test_fields_dict(self, C): """ Returns an ordered dict of ``{attribute_name: Attribute}``. """ d = fields_dict(C) assert isinstance(d, ordered_dict) assert list(fields(C)) == list(d.values()) assert [a.name for a in fields(C)] == [field_name for field_name in d]
def test_fields_dict(self, C): """ Returns an ordered dict of ``{attribute_name: Attribute}``. """ d = fields_dict(C) assert isinstance(d, ordered_dict) assert list(fields(C)) == list(d.values()) assert [a.name for a in fields(C)] == [field_name for field_name in d]