Exemplo n.º 1
0
    def test_invalid(self):
        prop = bcpc.Dict(String, bcpc.List(Int))

        assert not prop.is_valid(False)
        assert not prop.is_valid(True)
        assert not prop.is_valid(0)
        assert not prop.is_valid(1)
        assert not prop.is_valid(0.0)
        assert not prop.is_valid(1.0)
        assert not prop.is_valid(1.0 + 1.0j)

        assert not prop.is_valid("")
        assert not prop.is_valid(())
        assert not prop.is_valid([])
        assert not prop.is_valid({"foo": [1, 2, 3.5]})

        assert not prop.is_valid(np.array([1, 2, 3]))

        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Exemplo n.º 2
0
    def test_valid(self):
        prop = bcpc.Dict(String, bcpc.List(Int))

        assert prop.is_valid(None)
        assert prop.is_valid({})
        assert prop.is_valid({"foo": [1, 2, 3]})
Exemplo n.º 3
0
 def test_init(self):
     with pytest.raises(TypeError):
         bcpc.Dict()
Exemplo n.º 4
0
 def test_str(self):
     prop = bcpc.Dict(String, Int)
     assert str(prop) == "Dict(String, Int)"
Exemplo n.º 5
0
    def test_has_ref(self):
        prop = bcpc.Dict(String, Int)
        assert not prop.has_ref

        prop = bcpc.Dict(String, Instance(_TestModel))
        assert prop.has_ref
Exemplo n.º 6
0
 def test_wrap(self) -> None:
     prop = bcpc.Dict(String, Int)
     wrapped = prop.wrap({"foo": 10})
     assert isinstance(wrapped, PropertyValueDict)
     assert prop.wrap(wrapped) is wrapped