def test_invert_mapping(self): mapping = dict(one=1, two=2, three=3, four=4) expected = {1: 'one', 2: 'two', 3: 'three', 4: 'four'} actual = Plot2D._invert_mapping(mapping) self.assertEqual(actual, expected)
def test_bad_mapping(self): mapping = dict(one=1, two=2, three=3, four=1) emsg = 'Cannot invert non 1-to-1 mapping' with self.assertRaisesRegexp(ValueError, emsg): Plot2D._invert_mapping(mapping)