Skip to content

Commit 2988a82

Browse files
committed
test(color): update tests for immutable Color API
1 parent 78e9741 commit 2988a82

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

tests/test_color.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -57,47 +57,47 @@ def test_rgb_tuple(self):
5757

5858
def test_rgb_to_rgb(self):
5959
rgb = RGB(255, 128, 64)
60-
assert rgb.RGB() == rgb
61-
assert rgb.RGB() is not rgb
60+
assert rgb.to_rgb() == rgb
61+
assert rgb.to_rgb() is rgb
6262

6363
def test_rgb_to_hsv(self):
6464
rgb = RGB(255, 0, 0)
65-
hsv = rgb.HSV()
65+
hsv = rgb.to_hsv()
6666
assert hsv.hue == 0
6767
assert hsv.saturation == 100
6868
assert hsv.value == 100
6969

7070
def test_rgb_to_hsl(self):
7171
rgb = RGB(255, 0, 0)
72-
hsl = rgb.HSL()
72+
hsl = rgb.to_hsl()
7373
assert hsl.hue == 0
7474
assert hsl.saturation == 100
7575
assert hsl.lightness == 50
7676

7777
def test_rgb_to_cmyk(self):
7878
rgb = RGB(255, 0, 0)
79-
cmyk = rgb.CMYK()
79+
cmyk = rgb.to_cmyk()
8080
assert cmyk.cyan == 0
8181
assert cmyk.magenta == 100
8282
assert cmyk.yellow == 100
8383
assert cmyk.key == 0
8484

8585
def test_rgb_to_hex(self):
8686
rgb = RGB(255, 128, 64)
87-
hex_color = rgb.HEX()
87+
hex_color = rgb.to_hex()
8888
assert hex_color.value == "#ff8040"
8989

9090
def test_rgb_to_rgba(self):
9191
rgb = RGB(255, 128, 64)
92-
rgba = rgb.RGBA(0.5)
92+
rgba = rgb.to_rgba(0.5)
9393
assert rgba.red == 255
9494
assert rgba.green == 128
9595
assert rgba.blue == 64
9696
assert rgba.alpha == 0.5
9797

9898
def test_rgb_to_assa(self):
9999
rgb = RGB(255, 128, 64)
100-
assa = rgb.ASSA()
100+
assa = rgb.to_assa()
101101
assert assa.clean_value == "4080ff"
102102

103103

@@ -141,14 +141,14 @@ def test_rgba_equality(self):
141141

142142
def test_rgba_to_rgb(self):
143143
rgba = RGBA(255, 128, 64, 0.5)
144-
rgb = rgba.RGB()
144+
rgb = rgba.to_rgb()
145145
assert rgb.red == 255
146146
assert rgb.green == 128
147147
assert rgb.blue == 64
148148

149149
def test_rgba_to_assa(self):
150150
rgba = RGBA(255, 128, 64, 0.5)
151-
assa = rgba.ASSA()
151+
assa = rgba.to_assa()
152152
assert assa.alpha == 128
153153

154154

@@ -187,7 +187,7 @@ def test_hex_repr(self):
187187

188188
def test_hex_str(self):
189189
hex_color = HEX("#ff8040")
190-
assert hex_color.str() == "#ff8040"
190+
assert hex_color.to_str() == "#ff8040"
191191

192192
def test_hex_equality(self):
193193
hex1 = HEX("#ff8040")
@@ -198,7 +198,7 @@ def test_hex_equality(self):
198198

199199
def test_hex_to_rgb(self):
200200
hex_color = HEX("#ff8040")
201-
rgb = hex_color.RGB()
201+
rgb = hex_color.to_rgb()
202202
assert rgb.red == 255
203203
assert rgb.green == 128
204204
assert rgb.blue == 64
@@ -236,7 +236,7 @@ def test_hsv_repr(self):
236236

237237
def test_hsv_str(self):
238238
hsv = HSV(120, 50, 75)
239-
assert hsv.str() == "hsv(120.0°, 50.0%, 75.0%)"
239+
assert hsv.to_str() == "hsv(120.0°, 50.0%, 75.0%)"
240240

241241
def test_hsv_equality(self):
242242
hsv1 = HSV(120, 50, 75)
@@ -247,21 +247,21 @@ def test_hsv_equality(self):
247247

248248
def test_hsv_to_rgb(self):
249249
hsv = HSV(0, 100, 100)
250-
rgb = hsv.RGB()
250+
rgb = hsv.to_rgb()
251251
assert rgb.red == 255
252252
assert rgb.green == 0
253253
assert rgb.blue == 0
254254

255255
def test_hsv_to_rgb_green(self):
256256
hsv = HSV(120, 100, 100)
257-
rgb = hsv.RGB()
257+
rgb = hsv.to_rgb()
258258
assert rgb.red == 0
259259
assert rgb.green == 255
260260
assert rgb.blue == 0
261261

262262
def test_hsv_to_rgb_blue(self):
263263
hsv = HSV(240, 100, 100)
264-
rgb = hsv.RGB()
264+
rgb = hsv.to_rgb()
265265
assert rgb.red == 0
266266
assert rgb.green == 0
267267
assert rgb.blue == 255
@@ -299,7 +299,7 @@ def test_hsl_repr(self):
299299

300300
def test_hsl_str(self):
301301
hsl = HSL(120, 50, 75)
302-
assert hsl.str() == "hsl(120.0°, 50.0%, 75.0%)"
302+
assert hsl.to_str() == "hsl(120.0°, 50.0%, 75.0%)"
303303

304304
def test_hsl_equality(self):
305305
hsl1 = HSL(120, 50, 75)
@@ -310,14 +310,14 @@ def test_hsl_equality(self):
310310

311311
def test_hsl_to_rgb(self):
312312
hsl = HSL(0, 100, 50)
313-
rgb = hsl.RGB()
313+
rgb = hsl.to_rgb()
314314
assert rgb.red == 255
315315
assert rgb.green == 0
316316
assert rgb.blue == 0
317317

318318
def test_hsl_to_rgb_gray(self):
319319
hsl = HSL(0, 0, 50)
320-
rgb = hsl.RGB()
320+
rgb = hsl.to_rgb()
321321
assert rgb.red == 128
322322
assert rgb.green == 128
323323
assert rgb.blue == 128
@@ -360,7 +360,7 @@ def test_cmyk_repr(self):
360360

361361
def test_cmyk_str(self):
362362
cmyk = CMYK(25, 50, 75, 10)
363-
assert cmyk.str() == "cmyk(25.0%, 50.0%, 75.0%, 10.0%)"
363+
assert cmyk.to_str() == "cmyk(25.0%, 50.0%, 75.0%, 10.0%)"
364364

365365
def test_cmyk_equality(self):
366366
cmyk1 = CMYK(25, 50, 75, 10)
@@ -371,14 +371,14 @@ def test_cmyk_equality(self):
371371

372372
def test_cmyk_to_rgb(self):
373373
cmyk = CMYK(0, 100, 100, 0)
374-
rgb = cmyk.RGB()
374+
rgb = cmyk.to_rgb()
375375
assert rgb.red == 255
376376
assert rgb.green == 0
377377
assert rgb.blue == 0
378378

379379
def test_cmyk_to_rgb_black(self):
380380
cmyk = CMYK(0, 0, 0, 100)
381-
rgb = cmyk.RGB()
381+
rgb = cmyk.to_rgb()
382382
assert rgb.red == 0
383383
assert rgb.green == 0
384384
assert rgb.blue == 0
@@ -393,7 +393,7 @@ def test_assa_repr(self):
393393

394394
def test_assa_str(self):
395395
assa = ASSA("4080FF")
396-
assert assa.str() == "&H4080ff&"
396+
assert assa.to_str() == "&H4080ff&"
397397

398398
def test_assa_equality(self):
399399
assa1 = ASSA("4080FF")
@@ -418,7 +418,7 @@ def test_assa_format_detection(self):
418418

419419
def test_assa_to_rgb(self):
420420
assa = ASSA("4080FF")
421-
rgb = assa.RGB()
421+
rgb = assa.to_rgb()
422422
assert rgb.red == 255
423423
assert rgb.green == 128
424424
assert rgb.blue == 64
@@ -441,17 +441,17 @@ def test_assa_from_alpha(self):
441441

442442
def test_assa_from_rgb(self):
443443
rgb = RGB(255, 128, 64)
444-
assa = ASSA.from_RGB(rgb)
444+
assa = ASSA.from_rgb(rgb)
445445
assert assa.clean_value == "4080ff"
446446

447447
def test_assa_from_rgb_with_alpha(self):
448448
rgb = RGB(255, 128, 64)
449-
assa = ASSA.from_RGB(rgb, alpha=128)
449+
assa = ASSA.from_rgb(rgb, alpha=128)
450450
assert assa.clean_value == "804080ff"
451451

452452
def test_assa_from_rgba(self):
453453
rgba = RGBA(255, 128, 64, 0.5)
454-
assa = ASSA.from_RGBA(rgba)
454+
assa = ASSA.from_rgba(rgba)
455455
assert assa.clean_value == "804080ff"
456456

457457
def test_assa_new_constructor_bbggrr(self):
@@ -547,7 +547,7 @@ def test_webcolor_repr(self):
547547

548548
def test_webcolor_str(self):
549549
wc = webcolor("red")
550-
assert wc.str() == "red"
550+
assert wc.to_str() == "red"
551551

552552
def test_webcolor_equality(self):
553553
wc1 = webcolor("red")
@@ -558,7 +558,7 @@ def test_webcolor_equality(self):
558558

559559
def test_webcolor_to_rgb(self):
560560
wc = webcolor("red")
561-
rgb = wc.RGB()
561+
rgb = wc.to_rgb()
562562
assert rgb.red == 255
563563
assert rgb.green == 0
564564
assert rgb.blue == 0
@@ -617,43 +617,43 @@ def test_normalize_invalid_type(self):
617617
class TestColorConversions:
618618
def test_rgb_hsv_roundtrip(self):
619619
rgb = RGB(255, 128, 64)
620-
hsv = rgb.HSV()
621-
rgb2 = hsv.RGB()
620+
hsv = rgb.to_hsv()
621+
rgb2 = hsv.to_rgb()
622622
assert abs(rgb.red - rgb2.red) <= 1
623623
assert abs(rgb.green - rgb2.green) <= 1
624624
assert abs(rgb.blue - rgb2.blue) <= 1
625625

626626
def test_rgb_hsl_roundtrip(self):
627627
rgb = RGB(255, 128, 64)
628-
hsl = rgb.HSL()
629-
rgb2 = hsl.RGB()
628+
hsl = rgb.to_hsl()
629+
rgb2 = hsl.to_rgb()
630630
assert abs(rgb.red - rgb2.red) <= 1
631631
assert abs(rgb.green - rgb2.green) <= 1
632632
assert abs(rgb.blue - rgb2.blue) <= 1
633633

634634
def test_rgb_cmyk_roundtrip(self):
635635
rgb = RGB(255, 128, 64)
636-
cmyk = rgb.CMYK()
637-
rgb2 = cmyk.RGB()
636+
cmyk = rgb.to_cmyk()
637+
rgb2 = cmyk.to_rgb()
638638
assert abs(rgb.red - rgb2.red) <= 1
639639
assert abs(rgb.green - rgb2.green) <= 1
640640
assert abs(rgb.blue - rgb2.blue) <= 1
641641

642642
def test_rgb_hex_roundtrip(self):
643643
rgb = RGB(255, 128, 64)
644-
hex_color = rgb.HEX()
645-
rgb2 = hex_color.RGB()
644+
hex_color = rgb.to_hex()
645+
rgb2 = hex_color.to_rgb()
646646
assert rgb == rgb2
647647

648648
def test_rgb_assa_roundtrip(self):
649649
rgb = RGB(255, 128, 64)
650-
assa = rgb.ASSA()
651-
rgb2 = assa.RGB()
650+
assa = rgb.to_assa()
651+
rgb2 = assa.to_rgb()
652652
assert rgb == rgb2
653653

654654
def test_rgba_assa_roundtrip(self):
655655
rgba = RGBA(255, 128, 64, 0.5)
656-
assa = rgba.ASSA()
656+
assa = rgba.to_assa()
657657
rgba2 = RGBA.from_assa(assa)
658658
assert abs(rgba.alpha - rgba2.alpha) < 0.01
659659

@@ -690,10 +690,10 @@ def test_rgb_copy(self):
690690
rgb = RGB(255, 128, 64)
691691
rgb_copy = rgb.copy()
692692
assert rgb == rgb_copy
693-
assert rgb is not rgb_copy
693+
assert rgb is rgb_copy
694694

695695
def test_rgba_copy(self):
696696
rgba = RGBA(255, 128, 64, 0.5)
697697
rgba_copy = rgba.copy()
698698
assert rgba == rgba_copy
699-
assert rgba is not rgba_copy
699+
assert rgba is rgba_copy

0 commit comments

Comments
 (0)