Skip to content

Commit

Permalink
Correctly register empty sources (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed Aug 15, 2017
1 parent d4fff81 commit d7f2e60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(self, rename={}, source=None, subscribers=[], linked=False,
self._metadata = {}

super(Stream, self).__init__(**params)
if source:
if source is not None:
self.registry[id(source)].append(self)


Expand Down
19 changes: 19 additions & 0 deletions tests/teststreams.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""
Unit test of the streams system
"""
from collections import defaultdict

import param
from holoviews.element import Points
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import * # noqa (Test all available streams)

Expand Down Expand Up @@ -226,6 +229,22 @@ def test_batch_subscribers(self):
self.assertEqual(subscriber2.call_count, 1)


class TestStreamSource(ComparisonTestCase):

def tearDown(self):
Stream.registry = defaultdict(list)

def test_source_registry(self):
points = Points([(0, 0)])
positionX = PointerX(source=points)
self.assertIn(id(points), Stream.registry)

def test_source_registry_empty_element(self):
points = Points([])
positionX = PointerX(source=points)
self.assertIn(id(points), Stream.registry)


class TestParameterRenaming(ComparisonTestCase):

def test_simple_rename_constructor(self):
Expand Down

0 comments on commit d7f2e60

Please sign in to comment.