more Parameters fixup
This commit is contained in:
21
tests/test_type_checker.py
Normal file
21
tests/test_type_checker.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from scgenerator.parameter import type_checker
|
||||
|
||||
|
||||
def test_type_checker():
|
||||
numero = type_checker(int)
|
||||
|
||||
@numero
|
||||
def natural_number(name, n):
|
||||
if n < 0:
|
||||
raise ValueError(f"{name!r} must be positive")
|
||||
|
||||
with pytest.raises(TypeError, match="of type"):
|
||||
numero("a", np.arange(45))
|
||||
with pytest.raises(ValueError, match="positive"):
|
||||
natural_number("b", -1)
|
||||
with pytest.raises(TypeError, match="of type"):
|
||||
natural_number("c", 1.0)
|
||||
natural_number("d", 1)
|
||||
Reference in New Issue
Block a user