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


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:31