def test_set_state_version_1(self):
        # Test support of older state version
        expected_type = 'test-type'
        expected_uid = 'test-uid'
        expected_v = numpy.array([1, 2, 3])
        expected_v_b = BytesIO()
        # noinspection PyTypeChecker
        numpy.save(expected_v_b, expected_v)
        expected_v_dump = expected_v_b.getvalue()

        e = DescriptorMemoryElement(None, None)
        e.__setstate__((expected_type, expected_uid, expected_v_dump))
        self.assertEqual(e.type(), expected_type)
        self.assertEqual(e.uuid(), expected_uid)
        numpy.testing.assert_array_equal(e.vector(), expected_v)
Esempio n. 2
0
    def test_set_state_version_1(self):
        # Test support of older state version
        expected_type = 'test-type'
        expected_uid = 'test-uid'
        expected_v = numpy.array([1, 2, 3])
        expected_v_b = BytesIO()
        # noinspection PyTypeChecker
        numpy.save(expected_v_b, expected_v)
        expected_v_dump = expected_v_b.getvalue()

        e = DescriptorMemoryElement(None, None)
        e.__setstate__((expected_type, expected_uid, expected_v_dump))
        self.assertEqual(e.type(), expected_type)
        self.assertEqual(e.uuid(), expected_uid)
        numpy.testing.assert_array_equal(e.vector(), expected_v)