def test_init_palette_by_list(self): """ Test that a palette can be initialized by a list """ # Try all the values in the palettes (HEX) for value in PALETTES.values(): palette = ColorPalette(value) self.assertEqual(len(value), len(palette)) # Try all the values converted to RGB for value in PALETTES.values(): palette = ColorPalette(map(mpl.colors.colorConverter.to_rgb, value)) self.assertEqual(len(value), len(palette))
def test_init_palette_by_name(self): """ Test that a palette can be initialized by name """ # Try all the names in the palettes for name, value in PALETTES.items(): try: palette = ColorPalette(name) except YellowbrickValueError: self.fail( "Could not instantiate {} color palette by name".format(name) ) self.assertEqual(value, palette) # Try a name not in PALETTES with self.assertRaises(YellowbrickValueError): self.assertNotIn('foo', PALETTES, "Cannot test bad name 'foo' it is in PALETTES!") palette = ColorPalette('foo')
def test_init_palette_by_name(self): """ Test that a palette can be initialized by name """ # Try all the names in the palettes for name, value in PALETTES.items(): try: palette = ColorPalette(name) except YellowbrickValueError: self.fail( "Could not instantiate {} color palette by name".format( name)) assert value == palette # Try a name not in PALETTES with pytest.raises(YellowbrickValueError): assert ("foo" not in PALETTES ), "Cannot test bad name 'foo' it is in PALETTES!" palette = ColorPalette("foo")