From 70c83ef1652cec0d2fd2102fd55fb5f2e4465260 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sat, 24 Feb 2018 12:47:18 +0000 Subject: [PATCH] Fix tests on Python 2.7 --- glue/core/state_path_patches.txt | 1 + glue/core/tests/test_data_collection.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/glue/core/state_path_patches.txt b/glue/core/state_path_patches.txt index 44108609a..70c57e5e9 100644 --- a/glue/core/state_path_patches.txt +++ b/glue/core/state_path_patches.txt @@ -25,3 +25,4 @@ glue_vispy_viewers.common.toolbar.PatchedElementSubsetState -> glue.core.subset. glue.plugins.dendro_viewer.qt.viewer_widget.DendroWidget -> glue.plugins.dendro_viewer.qt.DendrogramViewer glue.plugins.dendro_viewer.layer_artist.DendroLayerArtist -> glue.plugins.dendro_viewer.layer_artist.DendrogramLayerArtist builtins.builtin_function_or_method -> types.BuiltinFunctionType +__builtin__.builtin_function_or_method -> types.BuiltinFunctionType diff --git a/glue/core/tests/test_data_collection.py b/glue/core/tests/test_data_collection.py index e6b7cda13..15eab0f4a 100644 --- a/glue/core/tests/test_data_collection.py +++ b/glue/core/tests/test_data_collection.py @@ -13,12 +13,13 @@ from ..data_collection import DataCollection from ..hub import HubListener from ..message import (Message, DataCollectionAddMessage, DataRemoveComponentMessage, - DataCollectionDeleteMessage, + DataCollectionDeleteMessage, DataAddComponentMessage, ComponentsChangedMessage, ExternallyDerivableComponentsChangedMessage) from ..exceptions import IncompatibleAttribute from .test_state import clone + class HubLog(HubListener): def __init__(self): @@ -30,6 +31,9 @@ def register_to_hub(self, hub): def notify(self, message): self.messages.append(message) + def clear(self): + self.messages[:] = [] + class TestDataCollection(object): @@ -159,10 +163,15 @@ def test_catch_data_add_component_message(self): self.dc.append(d) d.add_component(Component(np.array([1, 2, 3])), id1) assert link not in self.dc._link_manager + self.log.clear() d.add_component(dc, id2) - msg = self.log.messages[-1] - assert isinstance(msg, ComponentsChangedMessage) + msgs = sorted(self.log.messages) + + assert isinstance(msgs[0], ComponentsChangedMessage) + assert isinstance(msgs[1], DataAddComponentMessage) + assert isinstance(msgs[2], ExternallyDerivableComponentsChangedMessage) + assert link in self.dc._link_manager def test_links_auto_added(self):