bokeh.core.properties.Regex

Here are the examples of the python api bokeh.core.properties.Regex taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Source File : test_either.py
License : MIT License
Project Creator : rthorst

    def test_valid(self):
        prop = bcpe.Either(Interval(Int, 0, 100), Regex("^x*$"), List(Int))

        assert prop.is_valid(None)

        assert prop.is_valid(0)
        assert prop.is_valid(1)

        assert prop.is_valid("")
        assert prop.is_valid("xxx")
        assert prop.is_valid([])
        assert prop.is_valid([1, 2, 3])
        assert prop.is_valid(100)

        # TODO (bev) should fail
        assert prop.is_valid(False)
        assert prop.is_valid(True)

    def test_invalid(self):

3 View Source File : test_either.py
License : MIT License
Project Creator : rthorst

    def test_invalid(self):
        prop = bcpe.Either(Interval(Int, 0, 100), Regex("^x*$"), List(Int))

        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, ""])

    def test_has_ref(self):

3 View Source File : test_validation.py
License : MIT License
Project Creator : rthorst

    def test_Regex(self):
        p = Regex("green")
        with pytest.raises(ValueError) as e:
            p.validate("junk")
        assert not str(e).endswith("ValueError")
    def test_String(self):

3 View Source File : test_validation.py
License : MIT License
Project Creator : rthorst

    def test_Regex(self, detail):
        p = Regex("green")
        with pytest.raises(ValueError) as e:
            p.validate("junk", detail)
        assert str(e).endswith("ValueError") == (not detail)
    def test_String(self, detail):