Update tests/test_utils_typecast.py
Run CI Tests / test (push) Successful in 33s

This commit is contained in:
2025-07-29 23:33:06 +02:00
parent c0abb40fed
commit 8d5a66c4b8
+5 -6
View File
@@ -22,9 +22,6 @@ class Car:
def drive(self):
return "vroom"
# --- Tests ---
def test_downcast_success():
d = Dog()
downcast(d, Bulldog)
@@ -33,7 +30,7 @@ def test_downcast_success():
def test_upcast_success():
b = Bulldog()
assert d.snore() == "woooooof"
assert b.snore() == "woooooof"
assert not hasattr(d, "speak")
upcast(b, Dog)
assert b.speak() == "woof"
@@ -43,9 +40,11 @@ def test_upcast_success():
assert b.speak() == "..."
def test_downcast_invalid():
a = Animal()
class C: pass
class D: pass
c = C()
with pytest.raises(TypeError, match="is not a subclass"):
downcast(a, Bulldog)
downcast(c, D)
def test_upcast_invalid():
c = Car()