def test_create_legend_invalid_input(self): """Test raises error on bad input.""" fig, ax = plt.subplots() with npt.assert_raises(ValueError): _create_legend(ax, ['^', '<', '>'], ['dist1', 'dist2'], 'symbols') with npt.assert_raises(ValueError): _create_legend(ax, ['^', '<', '>'], ['dist1', 'dist2', 'dist3'], 'foo')
def test_create_legend(self): """_create_box_plot_legend() should create a legend on valid input.""" fig, ax = plt.subplots() _create_legend(ax, ['b', 'r'], ['dist1', 'dist2'], 'colors') self.assertEqual(len(ax.get_legend().get_texts()), 2) fig, ax = plt.subplots() _create_legend(ax, ['^', '<', '>'], ['dist1', 'dist2', 'dist3'], 'symbols') self.assertEqual(len(ax.get_legend().get_texts()), 3)