0.12.6 add unittest to dei_args()

This commit is contained in:
Yusur 2026-05-27 12:46:13 +02:00
parent e5a8c6bd61
commit d0701599fe
5 changed files with 41 additions and 11 deletions

31
tests/test_dei.py Normal file
View file

@ -0,0 +1,31 @@
import unittest
from suou import dei_args
class TestDei(unittest.TestCase):
def setUp(self) -> None:
...
def tearDown(self) -> None:
...
def test_dei_args(self):
def func_a(*, a: int, b: int):
"""Trivial function for the purpose of the test"""
return a - b == 0
func_b = dei_args(c='a', d='b')(func_a)
with self.assertRaises(TypeError):
func_a(c=1, b=2)
self.assertTrue(func_a(a=1, b=1))
self.assertFalse(func_b(c=1, b=2))
self.assertFalse(func_b(a=1, d=2))
self.assertFalse(func_b(a=1, b=2))
with self.assertRaises(TypeError):
func_b(c=1, b="a")

View file

@ -1,6 +1,4 @@
import unittest
from suou.strtools import PrefixIdentifier
@ -27,14 +25,11 @@ class TestStrtools(unittest.TestCase):
def test_PrefixIdentifier_get_nostr(self):
with self.assertRaises(TypeError):
pi = PrefixIdentifier(1)
pi.hello
PrefixIdentifier(1)
with self.assertRaises(TypeError):
PrefixIdentifier([99182])
with self.assertRaises(TypeError):
PrefixIdentifier(b'alpha_')