Exemple #1
0
    def test_errors(self):

        # Test passing an unsupported data type (should raise a Type Error)
        with self.assertRaises(TypeError):
            shm.write_list(self.string_variable, 'string', 'strings', 1)

        # Test passing an unsupported data type as a valid one (should raise a Type Error from C)
        # Note also this test also confirms that segments are properly cleaned up after an 
        # exception
        with self.assertRaises(TypeError):
            shm.write_list(self.string_variable, 'int', 'string', 1)

        # Test passing a valid data type with an invalid element (should raise a Type Error from C)
        with self.assertRaises(TypeError):
            shm.write_list(self.mixed_variable, 'int', 'mixed', 1)

        # Test passing a seed used by an existing segment (should raise an OS error from C)
        int_segment = shm.write_list(self.int_variable, 'int', 'ints', 1)
        with self.assertRaises(OSError):
            shm.write_list(self.int_variable, 'int', 'ints', 1)
        shm.deallocate(int_segment[1])

        # Test passing a data frame with unsupported columns (should raise a Type Error)
        bad_data = self.data.copy()
        bad_data.loc[:,'string_var'] = 'Hi'
        with self.assertRaises(TypeError):
            shm.write_frame(bad_data)
Exemple #2
0
    def test_basic(self):

        # Test essential basic functionality - these calls should all succeed
        float_segment = shm.write_list(self.float_variable, 'float', 'floats', 1)
        int_segment   = shm.write_list(self.int_variable, 'int', 'ints', 2)
        long_segment  = shm.write_list(self.long_variable, 'long', 'longs', 3)

        shm.deallocate(float_segment[1])
        shm.deallocate(int_segment[1])
        shm.deallocate(long_segment[1])