This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
from slic.utils.trinary import *
|
||||
|
||||
def test_check_trinary_valid_values():
|
||||
# These calls should not raise any exception and return None
|
||||
assert check_trinary(True) is None
|
||||
assert check_trinary(False) is None
|
||||
assert check_trinary(None) is None
|
||||
|
||||
def test_check_trinary_invalid_value():
|
||||
# These values are not allowed and should raise ValueError
|
||||
with pytest.raises(ValueError, match=r"Trinary .+ not in"):
|
||||
check_trinary("yes")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
check_trinary(0)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
check_trinary(1)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
check_trinary([])
|
||||
|
||||
def test_check_trinary_with_custom_allowed_values():
|
||||
# Valid custom values should pass without error
|
||||
assert check_trinary("maybe", allowed_values=("yes", "no", "maybe")) is None
|
||||
assert check_trinary("yes", allowed_values=("yes", "no", "maybe")) is None
|
||||
|
||||
# Invalid custom value should raise ValueError
|
||||
with pytest.raises(ValueError):
|
||||
check_trinary("never", allowed_values=("yes", "no", "maybe"))
|
||||
Reference in New Issue
Block a user