Esempio n. 1
0
    def test_invalid(self) -> None:
        prop = bcpc.Array(Float)

        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({})

        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 2
0
    def test_invalid(self) -> None:
        prop = bcpc.Color()
        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid((0, -127, 255))
        assert not prop.is_valid((0, 127))
        assert not prop.is_valid((0, 127, 1.0))
        assert not prop.is_valid((0, 127, 255, 255))

        assert not prop.is_valid('(0, 127, 255)')
        assert not prop.is_valid('rgb(0, -127, 255)')
        assert not prop.is_valid('rgb(0, 127)')
        assert not prop.is_valid('rgb(0, 127, 1.0)')
        assert not prop.is_valid('rgb(256, 1, 1)')
        assert not prop.is_valid('rgb(256, 1, 1, 1.0)')

        assert not prop.is_valid('(10, 20, 30')
        assert not prop.is_valid('rgba(10, 20, 30')
        assert not prop.is_valid('rgba(10, 20, 30)')
        assert not prop.is_valid('rgba(10, 20, 30,)')
        assert not prop.is_valid('rgba(10, 20)')
        assert not prop.is_valid('rgba(10, 20, 256, 1)')
        assert not prop.is_valid('rgba(10, 20, 256, 10)')
        assert not prop.is_valid('rgba(10, 20, 30, 50)')

        assert not prop.is_valid("00aaff")
        assert not prop.is_valid("00AAFF")
        assert not prop.is_valid("00AaFf")
        assert not prop.is_valid("#00AaFg")
        assert not prop.is_valid("#00AaFff")

        assert not prop.is_valid("foobar")
Esempio n. 3
0
    def test_invalid(self):
        prop = bcpn.PositiveInt()

        assert not prop.is_valid(False)

        assert not prop.is_valid(-1)
        assert not prop.is_valid(0)
        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid(-100)
        assert not prop.is_valid(-0.001)
Esempio n. 4
0
    def test_invalid(self) -> None:
        prop = bcpe.Either(Interval(Int, 0, 100), Regex("^x*$"), List(Int))

        assert not prop.is_valid(None)

        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(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid(-100)

        assert not prop.is_valid("yyy")

        assert not prop.is_valid([1, 2, ""])
Esempio n. 5
0
    def test_invalid(self) -> None:
        prop = bcpp.String()

        assert not prop.is_valid(None)
        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(b"")
        assert not prop.is_valid(b"some")

        assert not prop.is_valid(())
        assert not prop.is_valid([])
        assert not prop.is_valid({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 6
0
    def test_invalid(self):
        prop = bcpv.DashPattern()

        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("foo")
        assert not prop.is_valid("DASHDOT")

        assert not prop.is_valid([1, 2, 3.0])
        assert not prop.is_valid("1 2 x")

        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 7
0
    def test_invalid(self) -> None:
        prop = bcpr.Regex("^x*$")

        assert not prop.is_valid("xy")

        assert not prop.is_valid(None)
        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(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 8
0
    def test_invalid(self) -> None:
        prop = bcpp.Bool()

        assert not prop.is_valid(None)
        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid(np.int8(0))
        assert not prop.is_valid(np.int8(1))
        assert not prop.is_valid(np.int16(0))
        assert not prop.is_valid(np.int16(1))
        assert not prop.is_valid(np.int32(0))
        assert not prop.is_valid(np.int32(1))
        assert not prop.is_valid(np.int64(0))
        assert not prop.is_valid(np.int64(1))
        assert not prop.is_valid(np.uint8(0))
        assert not prop.is_valid(np.uint8(1))
        assert not prop.is_valid(np.uint16(0))
        assert not prop.is_valid(np.uint16(1))
        assert not prop.is_valid(np.uint32(0))
        assert not prop.is_valid(np.uint32(1))
        assert not prop.is_valid(np.uint64(0))
        assert not prop.is_valid(np.uint64(1))
        assert not prop.is_valid(np.float16(0))
        assert not prop.is_valid(np.float16(1))
        assert not prop.is_valid(np.float32(0))
        assert not prop.is_valid(np.float32(1))
        assert not prop.is_valid(np.float64(0))
        assert not prop.is_valid(np.float64(1))
        assert not prop.is_valid(np.complex64(1.0 + 1.0j))
        assert not prop.is_valid(np.complex128(1.0 + 1.0j))
        if hasattr(np, "complex256"):
            assert not prop.is_valid(np.complex256(1.0 + 1.0j))
Esempio n. 9
0
    def test_invalid(self):
        prop = bcpc.Seq(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(set([]))
        assert not prop.is_valid({})

        assert not prop.is_valid({1, 2})
        assert not prop.is_valid({1: 2})

        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 10
0
    def test_invalid(self):
        prop = 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([1,2,3.5])
        assert not prop.is_valid("")
        assert not prop.is_valid(())
        assert not prop.is_valid({})

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

        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 11
0
    def test_invalid(self) -> None:
        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())
Esempio n. 12
0
    def test_invalid(self):
        prop = bcpv.MarkerType()

        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid("string")

        assert not prop.is_valid([1, 2, 3])
        assert not prop.is_valid([1, 2, 3.0])
Esempio n. 13
0
    def test_invalid(self):
        prop = bcpj.JSON()

        assert not prop.is_valid("")
        assert not prop.is_valid("foo")
        assert not prop.is_valid("[]]")

        # json stickler for double quotes
        assert not prop.is_valid("[{'foo': 10}]")

        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(_TestHasProps())
        assert not prop.is_valid(_TestModel())
Esempio n. 14
0
    def test_invalid(self) -> None:
        prop = bcpc.RGB()
        assert not prop.is_valid(None)
        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid((0, 127, 255))
        assert not prop.is_valid((0, 127, 255, 1.0))
        assert not prop.is_valid((0, -127, 255))
        assert not prop.is_valid((0, 127))
        assert not prop.is_valid((0, 127, 1.0))
        assert not prop.is_valid((0, 127, 255, 255))

        assert not prop.is_valid("#00aaff")
        assert not prop.is_valid("#00AAFF")
        assert not prop.is_valid("#00AaFf")
        assert not prop.is_valid("00aaff")
        assert not prop.is_valid("00AAFF")
        assert not prop.is_valid("00AaFf")
        assert not prop.is_valid("#00AaFg")
        assert not prop.is_valid("#00AaFff")

        assert not prop.is_valid("blue")
        assert not prop.is_valid("BLUE")

        assert not prop.is_valid("foobar")
Esempio n. 15
0
    def test_from_enum_invalid(self) -> None:
        prop = bcpe.Enum(LineJoin)

        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid("MITER")
        assert not prop.is_valid("ROUND")
        assert not prop.is_valid("BEVEL")

        assert not prop.is_valid(" miter")
        assert not prop.is_valid(" round")
        assert not prop.is_valid(" bevel")
Esempio n. 16
0
    def test_from_values_invalid(self) -> None:
        prop = bcpe.Enum("red", "green", "blue")

        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({})
        assert not prop.is_valid(_TestHasProps())
        assert not prop.is_valid(_TestModel())

        assert not prop.is_valid("RED")
        assert not prop.is_valid("GREEN")
        assert not prop.is_valid("BLUE")

        assert not prop.is_valid(" red")
        assert not prop.is_valid(" green")
        assert not prop.is_valid(" blue")