コード例 #1
0
ファイル: test_themes.py プロジェクト: brianpanneton/bokeh
 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())
コード例 #2
0
ファイル: test_themes.py プロジェクト: jhnybida/milestone
 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())
コード例 #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)
コード例 #4
0
ファイル: test_themes.py プロジェクト: Apple3124/bokeh
 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)
コード例 #5
0
ファイル: test_themes.py プロジェクト: skyelong/Bokeh
    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']
コード例 #6
0
ファイル: test_themes.py プロジェクト: jhnybida/milestone
    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'])
コード例 #7
0
ファイル: test_themes.py プロジェクト: Apple3124/bokeh
 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'])
コード例 #8
0
ファイル: test_themes.py プロジェクト: digitalsatori/Bokeh
 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']
コード例 #9
0
ファイル: test_themes.py プロジェクト: zebulon2/bokeh
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"
コード例 #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']
コード例 #11
0
ファイル: test_themes.py プロジェクト: Apple3124/bokeh
 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'])
コード例 #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())
コード例 #13
0
ファイル: test_themes.py プロジェクト: Apple3124/bokeh
 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())