Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
def test_property_fixed_and_required():
    with pytest.raises(STIXError):
        Property(default=lambda: 3, required=True)
Ejemplo n.º 3
0
def test_property():
    p = Property()

    assert p.required is False
    assert p.clean('foo') == 'foo'
    assert p.clean(3) == 3
Ejemplo n.º 4
0
def test_property():
    p = Property()

    assert p.required is False