Update tests/test_ytils_utils.py
Run CI Tests / test (push) Successful in 2m50s

This commit is contained in:
2025-07-31 09:37:41 +02:00
parent e255fe4d24
commit 16de8cd747
+38 -3
View File
@@ -30,14 +30,49 @@ def test_singleton_identity():
# Test: typename()
@pytest.mark.parametrize("obj,expected", [
import pytest
import types
import math
import sys
# Une classe un peu plus complexe
def sample_function(x):
def nested(y):
return y + x
return nested
@pytest.mark.parametrize("obj, expected", [
(None, "NoneType"),
(True, "bool"),
(42, "int"),
("hello", "str"),
(test_singleton_class, "test_singleton_class"),
(3.14, "float"),
("text", "str"),
({1, 2, 3}, "set"),
([[1], [2, 3]], "list"),
([{"a": [1, 2]}, {"b": (3, 4)}], "list"),
({"key": [{"nested": 1}, (2, 3)]}, "dict"),
# Fonctions
(lambda x: x, "<lambda>"),
(sample_function, "sample_function"),
(sample_function(10), "nested"),
(len, "len"),
(sum, "sum"),
# Modules
(math, "math"),
(sys, "sys"),
(types.FunctionType, "FunctionType"),
((i for i in range(3)), "generator"),
(iter([1, 2, 3]), "list_iterator"),
])
def test_typename(obj, expected):
assert typename(obj) == expected
# Test: next_int()
@pytest.mark.parametrize("nums,expected", [