Skip to content

Commit

Permalink
[test] Updated 'kitty' render style tests
Browse files Browse the repository at this point in the history
- Fix: Corrected tests for `z_index` and `mix` style args.
- Add: Added tests for `method` style arg and format spec field.
  • Loading branch information
AnonymouX47 committed Jun 14, 2022
1 parent d39cbeb commit bc146ee
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/test_kitty.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def test_style_format_spec():

for spec, args in (
("", {}),
("L", {"method": LINES}),
("W", {"method": WHOLE}),
("z", {"z_index": None}),
("z0", {"z_index": 0}),
("z1", {"z_index": 1}),
Expand All @@ -77,7 +79,7 @@ def test_style_format_spec():
(f"z{-2**31}", {"z_index": -(2**31)}),
("m0", {"mix": False}),
("m1", {"mix": True}),
("z0m1", {"z_index": 0, "mix": True}),
("Wz0m1", {"method": WHOLE, "z_index": 0, "mix": True}),
):
assert KittyImage._check_style_format_spec(spec, spec) == args

Expand All @@ -88,6 +90,16 @@ def test_unknown(self):
with pytest.raises(KittyImageError, match="Unknown style-specific"):
KittyImage._check_style_args(args)

def test_method(self):
for value in (1.0, (), [], 2):
with pytest.raises(TypeError):
KittyImage._check_style_args({"method": value})
for value in ("", " ", "cool"):
with pytest.raises(ValueError):
KittyImage._check_style_args({"method": value})
for value in (LINES, WHOLE):
assert KittyImage._check_style_args({"method": value}) == {"method": value}

def test_z_index(self):
for value in (1.0, (), [], "2"):
with pytest.raises(TypeError):
Expand All @@ -96,14 +108,17 @@ def test_z_index(self):
with pytest.raises(ValueError):
KittyImage._check_style_args({"z_index": value})
for value in (None, 0, 1, -1, -(2**31), 2**31 - 1):
KittyImage._check_style_args({"z_index": value}) == {"z_index": value}
assert (
KittyImage._check_style_args({"z_index": value})
== {"z_index": value} # fmt: skip
)

def test_mix(self):
for value in (0, 1.0, (), [], "2"):
with pytest.raises(TypeError):
KittyImage._check_style_args({"mix": value})
for value in (True, False):
KittyImage._check_style_args({"mix": value}) == {"mix": value}
assert KittyImage._check_style_args({"mix": value}) == {"mix": value}


def expand_control_data(control_data):
Expand Down

0 comments on commit bc146ee

Please sign in to comment.