def test_print_PyomoAPIData_repr(self): #"""Print PyomoAPIData representation""" data = PyomoAPIData() data.a = 1 data.b = [1, 2] data.c = PyomoAPIData() data.c.x = 1 data.c.y = 2 data['aa'] = 'here is more' data.clean() # Because the PyomoAPIData is a dict, the repr() is subject to # change between python versions. Cast back to a dict and # verify. self.assertEqual( eval(repr(data)), eval("{'a': 1, 'aa': 'here is more', 'b': [1, 2], " "'c': {'y': 2, 'x': 1}}")) self.assertEqual(len(data._dirty_), 0)
def test_print_PyomoAPIData_string(self): #"""Print PyomoAPIData string""" data = PyomoAPIData() data.a = 1 data.b = [1, 2] data.c = PyomoAPIData() data.c.x = 1 data.c.y = 2 data['aa'] = 'here is more' data.clean() self.assertEqual(sorted(data.unused()), ['a', 'aa', 'b', 'c']) self.assertEqual( str(data), """a: 1 aa: here is more b: [1, 2] c: x: 1 y: 2""") self.assertEqual(len(data._dirty_), 0)