Ejemplo n.º 1
0
 def test_construct_empty_theme_from_file(self):
     with (tempfile.NamedTemporaryFile()) as file:
         # create and apply empty theme with no exception thrown
         file.file.write("".encode('utf-8'))
         file.file.flush()
         theme = Theme(filename=file.name)
         theme.apply_to_model(ThemedModel())
Ejemplo n.º 2
0
 def test_construct_empty_theme_from_file(self):
     with (tempfile.NamedTemporaryFile()) as file:
         # create and apply empty theme with no exception thrown
         file.file.write("".encode('utf-8'))
         file.file.flush()
         theme = Theme(filename=file.name)
         theme.apply_to_model(ThemedModel())
Ejemplo n.º 3
0
 def test_construct_empty_theme_from_file(self):
     # windows will throw permissions error with auto-delete
     with (tempfile.NamedTemporaryFile(delete=False)) as file:
         # create and apply empty theme with no exception thrown
         file.file.write("".encode('utf-8'))
         file.file.flush()
         theme = Theme(filename=file.name)
         theme.apply_to_model(ThemedModel())
     file.close()
     os.remove(file.name)
Ejemplo n.º 4
0
 def test_construct_empty_theme_from_file(self):
     # windows will throw permissions error with auto-delete
     with (tempfile.NamedTemporaryFile(delete=False)) as file:
         # create and apply empty theme with no exception thrown
         file.file.write("".encode('utf-8'))
         file.file.flush()
         theme = Theme(filename=file.name)
         theme.apply_to_model(ThemedModel())
     file.close()
     os.remove(file.name)
Ejemplo n.º 5
0
    def test_theming_a_model_via_base(self) -> None:
        theme = Theme(json={'attrs': {'ThemedModel': {'string': 'w00t'}}})
        obj = SubOfThemedModel()
        changes = dict(calls=[])

        def record_trigger(attr, old, new_):
            changes['calls'].append((attr, old, new_))

        obj.on_change('string', record_trigger)
        assert 'hello' == obj.string
        theme.apply_to_model(obj)
        assert 'w00t' == obj.string
        assert [('string', 'hello', 'w00t')] == changes['calls']
Ejemplo n.º 6
0
    def test_theming_a_model_via_base(self):
        theme = Theme(json={'attrs': {'ThemedModel': {'string': 'w00t'}}})
        obj = SubOfThemedModel()
        changes = dict(calls=[])

        def record_trigger(attr, old, new_):
            changes['calls'].append((attr, old, new_))

        obj.on_change('string', record_trigger)
        self.assertEqual('hello', obj.string)
        theme.apply_to_model(obj)
        self.assertEqual('w00t', obj.string)
        self.assertEqual([('string', 'hello', 'w00t')], changes['calls'])
Ejemplo n.º 7
0
 def test_theming_a_model_via_base(self):
     theme = Theme(json={
         'attrs' : {
             'ThemedModel' : {
                 'string' : 'w00t'
             }
         }
     })
     obj = SubOfThemedModel()
     changes = dict(calls=[])
     def record_trigger(attr, old, new_):
         changes['calls'].append((attr, old, new_))
     obj.on_change('string', record_trigger)
     self.assertEqual('hello', obj.string)
     theme.apply_to_model(obj)
     self.assertEqual('w00t', obj.string)
     self.assertEqual([('string', 'hello', 'w00t')], changes['calls'])
Ejemplo n.º 8
0
 def test_theming_a_model(self):
     theme = Theme(json={
         'attrs' : {
             'ThemedModel' : {
                 'string' : 'w00t'
             }
         }
     })
     obj = ThemedModel()
     changes = dict(calls=[])
     assert 'hello' == obj.string
     def record_trigger(attr, old, new_):
         changes['calls'].append((attr, old, new_))
     obj.on_change('string', record_trigger)
     theme.apply_to_model(obj)
     assert 'w00t' == obj.string
     assert [('string', 'hello', 'w00t')] == changes['calls']
Ejemplo n.º 9
0
def test_theming_Figure_DEPRECATED() -> None:
    with pytest.warns(BokehDeprecationWarning):
        theme = Theme(json={
            "attrs": {
                "Figure": {
                    "background_fill_color": "#20262B",
                },
            },
        })
    obj = figure()
    changes = dict(calls=[])
    assert obj.background_fill_color != "#20262B"

    def record_trigger(attr, old, new_):
        changes['calls'].append((attr, old, new_))

    obj.on_change('background_fill_color', record_trigger)
    theme.apply_to_model(obj)
    assert obj.background_fill_color == "#20262B"
Ejemplo n.º 10
0
 def test_subclass_theme_used_rather_than_base(self):
     theme = Theme(json={
         'attrs' : {
             'ThemedModel' : {
                 'string' : 'w00t'
             },
             'SubOfThemedModel' : {
                 'string' : 'bar'
             }
         }
     })
     obj = SubOfThemedModel()
     assert 'hello' == obj.string
     changes = dict(calls=[])
     def record_trigger(attr, old, new_):
         changes['calls'].append((attr, old, new_))
     obj.on_change('string', record_trigger)
     theme.apply_to_model(obj)
     assert 'bar' == obj.string
     assert [('string', 'hello', 'bar')] == changes['calls']
Ejemplo n.º 11
0
 def test_subclass_theme_used_rather_than_base(self):
     theme = Theme(json={
         'attrs' : {
             'ThemedModel' : {
                 'string' : 'w00t'
             },
             'SubOfThemedModel' : {
                 'string' : 'bar'
             }
         }
     })
     obj = SubOfThemedModel()
     self.assertEqual('hello', obj.string)
     changes = dict(calls=[])
     def record_trigger(attr, old, new_):
         changes['calls'].append((attr, old, new_))
     obj.on_change('string', record_trigger)
     theme.apply_to_model(obj)
     self.assertEqual('bar', obj.string)
     self.assertEqual([('string', 'hello', 'bar')], changes['calls'])
Ejemplo n.º 12
0
 def test_construct_empty_theme_from_json(self):
     # create and apply empty theme with no exception thrown
     theme = Theme(json=dict())
     theme.apply_to_model(ThemedModel())
Ejemplo n.º 13
0
 def test_construct_empty_theme_from_json(self):
     # create and apply empty theme with no exception thrown
     theme = Theme(json=dict())
     theme.apply_to_model(ThemedModel())