Example #1
0
    def test_rgb_percent_to_name(self):
        """
        Test conversion from percent RGB triplet to color name.
        """
        test_pairs = (((u'100%', u'100%', u'100%'),
                       u'white'), ((u'0%', u'0%', u'50%'), u'navy'),
                      ((u'85.49%', u'64.71%', u'12.5%'), u'goldenrod'))

        for triplet, name in test_pairs:
            self.assertEqual(name, webcolors.rgb_percent_to_name(triplet))
Example #2
0
    def test_rgb_percent_to_name(self):
        """
        Test conversion from percent RGB triplet to color name.
        """
        test_pairs = (((u'100%', u'100%', u'100%'), u'white'),
                      ((u'0%', u'0%', u'50%'), u'navy'),
                      ((u'85.49%', u'64.71%', u'12.5%'), u'goldenrod'))

        for triplet, name in test_pairs:
            self.assertEqual(name,
                             webcolors.rgb_percent_to_name(triplet))
Example #3
0
    def test_rgb_percent_to_name(self):
        """
        Test conversion from percent RGB triplet to color name.
        """
        test_pairs = (
            ((u"100%", u"100%", u"100%"), u"white"),
            ((u"0%", u"0%", u"50%"), u"navy"),
            ((u"85.49%", u"64.71%", u"12.5%"), u"goldenrod"),
        )

        for triplet, name in test_pairs:
            self.assertEqual(name, webcolors.rgb_percent_to_name(triplet))
    def test_rgb_percent_to_name(self):
        """
        Test conversion from percent RGB triplet to color name.
        """
        test_pairs = (
            (("100%", "100%", "100%"), "white"),
            (("0%", "0%", "50%"), "navy"),
            (("85.49%", "64.71%", "12.5%"), "goldenrod"),
            (webcolors.PercentRGB("85.49%", "64.71%", "12.5%"), "goldenrod"),
        )

        for triplet, name in test_pairs:
            assert name == webcolors.rgb_percent_to_name(triplet)
Example #5
0
    def test_rgb_percent_to_name_specs(self):
        """
        Using one of the supported specifications succeeds; an
        unsupported specification raises ValueError.

        """
        for supported_spec in (u"html4", u"css2", u"css21", u"css3"):
            self.assertEqual(u"white", webcolors.rgb_percent_to_name((u"100%", u"100%", u"100%"), spec=supported_spec))

        for unsupported_spec in (u"css1", u"css4", u"html5"):
            self.assertRaises(
                ValueError, webcolors.rgb_percent_to_name, (u"100%", u"100%", u"100%"), spec=unsupported_spec
            )
Example #6
0
    def test_rgb_percent_to_name_specs(self):
        """
        Using one of the supported specifications succeeds; an
        unsupported specification raises ValueError.
        """
        for supported_spec in (u'html4', u'css2', u'css21', u'css3'):
            self.assertEqual(u'white',
                             webcolors.rgb_percent_to_name(
                                 (u'100%', u'100%', u'100%'),
                                 spec=supported_spec))

        for unsupported_spec in (u'css1', u'css4', u'html5'):
            self.assertRaises(ValueError,
                              webcolors.rgb_percent_to_name,
                              (u'100%', u'100%', u'100%'),
                              spec=unsupported_spec)
Example #7
0
    def test_rgb_percent_to_name_specs(self):
        """
        Using one of the supported specifications succeeds; an
        unsupported specification raises ValueError.
        """
        for supported_spec in (u'html4', u'css2', u'css21', u'css3'):
            self.assertEqual(u'white',
                             webcolors.rgb_percent_to_name(
                                 (u'100%', u'100%', u'100%'),
                                 spec=supported_spec))

        for unsupported_spec in (u'css1', u'css4', u'html5'):
            self.assertRaises(ValueError,
                              webcolors.rgb_percent_to_name,
                              (u'100%', u'100%', u'100%'),
                              spec=unsupported_spec)
	def test_rgb_percent_to_name_specs(self):
		"""
		Using one of the supported specifications succeeds; an
		unsupported specification raises ValueError.

		"""
		for supported_spec in ("html4", "css2", "css21", "css3"):
			result = webcolors.rgb_percent_to_name(("100%", "100%", "100%"), spec=supported_spec)
			assert "white" == result

		for unsupported_spec in ("css1", "css4", "html5"):
			self.assertRaises(
					ValueError,
					webcolors.rgb_percent_to_name,
					("100%", "100%", "100%"),
					spec=unsupported_spec,
					)