'Test assigning a value to a variable.'

def test_assign_var_value(self):

    a = Variable()
    a.value = 1
    self.assertEqual(a.value, 1)
    with self.assertRaises(Exception) as cm:
        a.value = [2, 1]
    self.assertEqual(str(cm.exception), 'Invalid    dimensions    (2,    1)    for    Variable    value.')
    a.value = 1
    a.value = None
    assert (a.value is None)
    x = Variable(2)
    x.value = [2, 1]
    self.assertItemsAlmostEqual(x.value, [2, 1])
    A = Variable(3, 2)
    A.value = np.ones((3, 2))
    self.assertItemsAlmostEqual(A.value, np.ones((3, 2)))
    x = NonNegative()
    with self.assertRaises(Exception) as cm:
        x.value = (-2)
    self.assertEqual(str(cm.exception), 'Invalid    sign    for    NonNegative    value.')
