diff --git a/wagtail/wagtailcore/blocks/stream_block.py b/wagtail/wagtailcore/blocks/stream_block.py index 40f6a29a2e..1c15904d95 100644 --- a/wagtail/wagtailcore/blocks/stream_block.py +++ b/wagtail/wagtailcore/blocks/stream_block.py @@ -361,6 +361,9 @@ class StreamValue(collections.Sequence): return self.stream_data == other.stream_data + def __ne__(self, other): + return not self.__eq__(other) + def __len__(self): return len(self.stream_data) diff --git a/wagtail/wagtailcore/tests/test_blocks.py b/wagtail/wagtailcore/tests/test_blocks.py index 517d08fc42..726ee53f1a 100644 --- a/wagtail/wagtailcore/tests/test_blocks.py +++ b/wagtail/wagtailcore/tests/test_blocks.py @@ -2203,6 +2203,20 @@ class TestStreamBlock(SimpleTestCase): self.assertEqual(stream_value[0].block_type, 'heading') self.assertEqual(stream_value[0].value, 'A different default heading') + def test_stream_value_equality(self): + block = blocks.StreamBlock([ + ('text', blocks.CharBlock()), + ]) + value1 = block.to_python([{'type': 'text', 'value': 'hello'}]) + value2 = block.to_python([{'type': 'text', 'value': 'hello'}]) + value3 = block.to_python([{'type': 'text', 'value': 'goodbye'}]) + + self.assertTrue(value1 == value2) + self.assertFalse(value1 != value2) + + self.assertFalse(value1 == value3) + self.assertTrue(value1 != value3) + class TestPageChooserBlock(TestCase): fixtures = ['test.json']