Fix StreamValue != operator on Python 2

pull/3275/merge
Matt Westcott 2017-02-03 17:02:34 +00:00
rodzic 6bdbaab681
commit 5b677af33b
2 zmienionych plików z 17 dodań i 0 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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']