test_tagbased_polymorphic.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 from pybind11_tests import tagbased_polymorphic as m
4 
5 
7  zoo = m.create_zoo()
8  assert [type(animal) for animal in zoo] == [
9  m.Labrador,
10  m.Dog,
11  m.Chihuahua,
12  m.Cat,
13  m.Panther,
14  ]
15  assert [animal.name for animal in zoo] == [
16  "Fido",
17  "Ginger",
18  "Hertzl",
19  "Tiger",
20  "Leo",
21  ]
22  zoo[1].sound = "woooooo"
23  assert [dog.bark() for dog in zoo[:3]] == [
24  "Labrador Fido goes WOOF!",
25  "Dog Ginger goes woooooo",
26  "Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles",
27  ]
28  assert [cat.purr() for cat in zoo[3:]] == ["mrowr", "mrrrRRRRRR"]
29  zoo[0].excitement -= 1000
30  assert zoo[0].excitement == 14000
type
Definition: pytypes.h:1525
test_tagbased_polymorphic.test_downcast
def test_downcast()
Definition: test_tagbased_polymorphic.py:6


gtsam
Author(s):
autogenerated on Thu Jul 4 2024 03:06:05