Example #1
0
def test_to_strings():
    """Test toString methods"""
    cunittest.assert_equals("(30, 240, 230)", a3.rgb_to_string(colormodel.RGB(30, 240, 230)))
    cunittest.assert_equals("(0, 0, 0)", a3.rgb_to_string(colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals("(255, 255, 255)", a3.rgb_to_string(colormodel.RGB(255, 255, 255)))
    cunittest.assert_equals("(0.000, 0.000, 0.000, 0.000)", a3.cmyk_to_string(colormodel.CMYK(0.0, 0.0, 0.0, 0.0)))
    cunittest.assert_equals(
        "(100.0, 100.0, 100.0, 100.0)", a3.cmyk_to_string(colormodel.CMYK(100.0, 100.0, 100.0, 100.0))
    )
    cunittest.assert_equals("(5.000, 56.50, 100.0, 11.60)", a3.cmyk_to_string(colormodel.CMYK(5, 56.5, 100.00, 11.598)))
    cunittest.assert_equals("(359.9, 1.000, 1.000)", a3.hsv_to_string(colormodel.HSV(359.9, 1.0, 1.0)))
    cunittest.assert_equals("(0.000, 0.000, 0.000)", a3.hsv_to_string(colormodel.HSV(0.0, 0.0, 0.0)))
    cunittest.assert_equals("(157.0, 0.568, 0.400)", a3.hsv_to_string(colormodel.HSV(157, 0.56789, 0.4)))
Example #2
0
def test_to_strings():
    """Test toString methods"""
    cunittest.assert_equals("(30, 240, 230)",  a3.rgb_to_string(\
                                        colormodel.RGB(30, 240, 230)))
    cunittest.assert_equals("(0, 0, 0)",  a3.rgb_to_string(\
                                        colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals("(30.00, 80.00, 59.00, 2.000)",  a3.cmyk_to_string(\
                                        colormodel.CMYK(30, 80, 59, 2)))
    cunittest.assert_equals("(30.99, 20.01, 9.256, 40.00)",  a3.cmyk_to_string(\
                                        colormodel.CMYK(30.98795, 20.00976, 9.2563, 40)))
    cunittest.assert_equals("(90.00, 0.280, 0.800)",  a3.hsv_to_string(\
                                        colormodel.HSV(90, .28, .8)))
    cunittest.assert_equals("(90.37, 0.289, 0.995)",  a3.hsv_to_string(\
                                        colormodel.HSV(90.368, .289303, .99508)))
Example #3
0
def test_to_strings():
    """Test toString methods"""
    #Test rgb_to_string:()
    cunittest.assert_equals("(30, 240, 230)",
                            a3.rgb_to_string(colormodel.RGB(30, 240, 230)));
    
    #Test cmyk_to_string()
    cunittest.assert_equals("(10.00, 11.00, 20.00, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10, 11, 20, 12)));
    #Test that cmyk_to_string() uses round5(), not `truncate5()`:
    cunittest.assert_equals("(10.01, 11.00, 20.01, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10.005, 11.0045,
                                                              20.009, 12.001)));

    #Test hsv_to_string()
    cunittest.assert_equals("(100.0, 1.000, 1.000)",
                            a3.hsv_to_string(colormodel.HSV(100, 1, 1)));
    #Test that hsv_to_string uses round5(), not `truncate5()`:
    cunittest.assert_equals("(100.0, 0.500, 0.499)",
                            a3.hsv_to_string(colormodel.HSV(99.999, .4996, .4994)));
Example #4
0
def test_to_strings():
    """Test toString methods"""
    #Test rgb_to_string:()
    cunittest.assert_equals("(30, 240, 230)",
                            a3.rgb_to_string(colormodel.RGB(30, 240, 230)))

    #Test cmyk_to_string()
    cunittest.assert_equals("(10.00, 11.00, 20.00, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10, 11, 20, 12)))
    #Test that cmyk_to_string() uses round5(), not `truncate5()`:
    cunittest.assert_equals(
        "(10.01, 11.00, 20.01, 12.00)",
        a3.cmyk_to_string(colormodel.CMYK(10.005, 11.0045, 20.009, 12.001)))

    #Test hsv_to_string()
    cunittest.assert_equals("(100.0, 1.000, 1.000)",
                            a3.hsv_to_string(colormodel.HSV(100, 1, 1)))
    #Test that hsv_to_string uses round5(), not `truncate5()`:
    cunittest.assert_equals(
        "(100.0, 0.500, 0.499)",
        a3.hsv_to_string(colormodel.HSV(99.999, .4996, .4994)))
Example #5
0
 def __str__(self):
     """Returns: Readable string representation of this color. """
     from a3 import rgb_to_string # local to prevent circular import
     return rgb_to_string(self)
Example #6
0
 def __str__(self):
     """Returns: Readable string representation of this color. """
     from a3 import rgb_to_string # local to prevent circular import
     return rgb_to_string(self)