Skip to content

Commit 952cb49

Browse files
committed
clean up
1 parent 3ad157c commit 952cb49

4 files changed

Lines changed: 18 additions & 49 deletions

File tree

holoviews/tests/core/test_dynamic.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -917,32 +917,23 @@ def test_dynamic_rx(self):
917917
assert_element_equal(dmap[()], hv.Curve(sine_array(0, 2)))
918918

919919

920-
class TestStreamSubscribersAddandClear:
921-
def setup_method(self):
922-
self.fn1 = lambda x: x
923-
self.fn2 = lambda x: x**2
924-
self.fn3 = lambda x: x**3
925-
self.fn4 = lambda x: x**4
926-
927-
# Precedence one and below is the user range, above one is reserved for
928-
# HoloViews, as documented on Stream.add_subscriber
929-
@pytest.mark.parametrize(
930-
("policy", "remaining"),
931-
[
932-
("all", []),
933-
("user", ["fn3", "fn4"]),
934-
("internal", ["fn1", "fn2"]),
935-
],
936-
)
937-
def test_subscriber_clear(self, policy, remaining):
938-
pointerx = PointerX(x=2)
939-
pointerx.add_subscriber(self.fn1, precedence=0)
940-
pointerx.add_subscriber(self.fn2, precedence=1)
941-
pointerx.add_subscriber(self.fn3, precedence=1.5)
942-
pointerx.add_subscriber(self.fn4, precedence=10)
943-
assert pointerx.subscribers == [self.fn1, self.fn2, self.fn3, self.fn4]
944-
pointerx.clear(policy)
945-
assert pointerx.subscribers == [getattr(self, name) for name in remaining]
920+
@pytest.mark.parametrize(
921+
("policy", "remaining"),
922+
[("all", []), ("user", ["fn3", "fn4"]), ("internal", ["fn1", "fn2"])],
923+
)
924+
def test_subscriber_clear(self, policy, remaining):
925+
self.fn1 = lambda x: x
926+
self.fn2 = lambda x: x**2
927+
self.fn3 = lambda x: x**3
928+
self.fn4 = lambda x: x**4
929+
pointerx = PointerX(x=2)
930+
pointerx.add_subscriber(self.fn1, precedence=0)
931+
pointerx.add_subscriber(self.fn2, precedence=1)
932+
pointerx.add_subscriber(self.fn3, precedence=1.5)
933+
pointerx.add_subscriber(self.fn4, precedence=10)
934+
assert pointerx.subscribers == [self.fn1, self.fn2, self.fn3, self.fn4]
935+
pointerx.clear(policy)
936+
assert pointerx.subscribers == [getattr(self, name) for name in remaining]
946937

947938

948939
class TestDynamicStreamReset:

holoviews/tests/plotting/bokeh/test_plot.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ def test_overlay_plot_stream_cleanup():
115115

116116
plot = bokeh_renderer.get_plot(dmap1 * dmap2)
117117

118-
# The overlay plot subscribes once per stream. It used to subscribe four
119-
# times, as attach_streams compared the refresh method against the
120-
# (precedence, subscriber) pairs and so never recognised it
121118
assert stream1.subscribers == [plot.refresh]
122119
assert stream2.subscribers == [plot.refresh]
123120

holoviews/tests/plotting/plotly/test_plot.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ def test_overlay_plot_stream_cleanup():
3737

3838
plot = plotly_renderer.get_plot(dmap1 * dmap2)
3939

40-
# The overlay plot subscribes once per stream. It used to subscribe four
41-
# times, as attach_streams compared the refresh method against the
42-
# (precedence, subscriber) pairs and so never recognised it
4340
assert stream1.subscribers == [plot.refresh]
4441
assert stream2.subscribers == [plot.refresh]
4542

holoviews/tests/test_streams.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -828,24 +828,14 @@ def on_update(self, **kwargs):
828828
self.calls.append(kwargs)
829829

830830

831-
def _closure(app):
832-
def on_update(**kwargs):
833-
app.calls.append(kwargs)
834-
835-
return on_update
836-
837-
838-
# The four ways a subscriber can reach back into its owner. Only the first two
839-
# were ever wrapped weakly, so the closure forms have always leaked.
840831
subscriber_kinds = pytest.mark.parametrize(
841832
"make_subscriber",
842833
[
843834
lambda app: app.on_update,
844835
lambda app: partial(app.on_update, extra=1),
845-
_closure,
846836
lambda app: lambda **kwargs: app.calls.append(kwargs),
847837
],
848-
ids=["bound_method", "partial", "closure", "lambda"],
838+
ids=["bound_method", "partial", "lambda"],
849839
)
850840

851841

@@ -916,8 +906,6 @@ def test_distinct_partials_not_deduplicated(self):
916906

917907
class TestStreamSource:
918908
def teardown_method(self):
919-
# Only drop the leftover entries, replacing the registry itself would
920-
# swap in a strongly keyed mapping and mask any leak
921909
with param.logging_level("ERROR"):
922910
Stream.registry.clear()
923911

@@ -951,10 +939,6 @@ def test_source_registry_empty_element(self):
951939
assert points in Stream.registry
952940

953941
def test_source_registry_releases_source(self):
954-
# The registry indexes its streams weakly, so an entry can never keep
955-
# its own source alive, not even through a subscriber reaching back to
956-
# it (#6875). Collecting the source drops the entry with it, as the
957-
# registry is still keyed weakly.
958942
def build():
959943
points = hv.Points([(0, 0)])
960944
stream = PointerX(source=points)

0 commit comments

Comments
 (0)