Skip to content

Commit

Permalink
Add boolean control test
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagocoutinho committed Aug 29, 2024
1 parent a319100 commit a76048c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,22 @@ def _():

assert "<Integer64Control integer_64_bits" in repr(integer_64_bits)

# boolean
boolean = controls.boolean
assert boolean is controls["boolean"]
assert boolean.value in (True, False)
boolean.value = False
assert boolean.value is False
boolean.value = True
assert boolean.value is True
trues = ["true", "1", "yes", "on", "enable", True, 1, [1], {1: 2}, (1,)]
falses = ["false", "0", "no", "off", "disable", False, 0, [], {}, (), None]
interleaved = (value for pair in zip(trues, falses) for value in pair)
for i, value in enumerate(interleaved):
expected = not bool(i % 2)
boolean.value = value
assert boolean.value is expected

# String
assert controls.string is controls["string"]
current_value = controls.string.value
Expand Down

0 comments on commit a76048c

Please sign in to comment.