Added 6 unit tests of dimension repr and its evaluation
@@ -49,6 +49,34 @@ class DimensionNameLabelTest(ComparisonTestCase):
with self.assertRaisesRegexp(KeyError, regexp):
dim = Dimension(('test', 'test dimension'), name='something else')
+
+class DimensionReprTest(ComparisonTestCase):
+
+ def test_name_dimension_repr(self):
+ dim = Dimension('test')
+ self.assertEqual(repr(dim), "Dimension('test')")
+
+ def test_name_dimension_repr_eval_equality(self):
+ dim = Dimension('test')
+ self.assertEqual(eval(repr(dim)) == dim, True)
+
+ def test_name_dimension_repr_tuple(self):
+ dim = Dimension(('test', 'Test Dimension'))
+ self.assertEqual(repr(dim), "Dimension('test', label='Test Dimension')")
+
+ def test_name_dimension_repr_tuple_eval_equality(self):
+ dim = Dimension(('test', 'Test Dimension'))
+ self.assertEqual(eval(repr(dim)) == dim, True)
+
+ def test_name_dimension_repr_params(self):
+ dim = Dimension('test', label='Test Dimension', unit='m')
+ self.assertEqual(repr(dim), "Dimension('test', label='Test Dimension', unit='m')")
+
+ def test_name_dimension_repr_params_eval_equality(self):
+ dim = Dimension('test', label='Test Dimension', unit='m')
+ self.assertEqual(eval(repr(dim)) == dim, True)
+
+
class DimensionValuesTest(ComparisonTestCase):
def setUp(self):
