def test_fixed_property(): p = Property(fixed="2.0") assert p.clean("2.0") with pytest.raises(ValueError): assert p.clean("x") is False with pytest.raises(ValueError): assert p.clean(2.0) is False assert p.default() == "2.0" assert p.clean(p.default())
def test_property_fixed_and_required(): with pytest.raises(STIXError): Property(default=lambda: 3, required=True)
def test_property(): p = Property() assert p.required is False assert p.clean('foo') == 'foo' assert p.clean(3) == 3
def test_property(): p = Property() assert p.required is False