Exemple #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())
Exemple #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]})
Exemple #3
0
 def test_init(self):
     with pytest.raises(TypeError):
         bcpc.Dict()
Exemple #4
0
 def test_str(self):
     prop = bcpc.Dict(String, Int)
     assert str(prop) == "Dict(String, Int)"
Exemple #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
Exemple #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