diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-05-09 19:22:53 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-05-22 17:15:09 +0000 |
commit | 6914a229a038206341ae1fea46393965a555ca9a (patch) | |
tree | 4a11cfaed46dabc827c5ee17cd976f42b5f53d49 /ext/pybind11/tests/test_inheritance.py | |
parent | ca1d18d599dcc620bf526fb22042af95b1b60b68 (diff) | |
download | gem5-6914a229a038206341ae1fea46393965a555ca9a.tar.xz |
ext: Upgrade PyBind11 to version 2.1.1
Change-Id: I16870dec402d661295f9d013dc23e362b2b2c169
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/3225
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'ext/pybind11/tests/test_inheritance.py')
-rw-r--r-- | ext/pybind11/tests/test_inheritance.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/ext/pybind11/tests/test_inheritance.py b/ext/pybind11/tests/test_inheritance.py index 7bb52be02..d1f537d1d 100644 --- a/ext/pybind11/tests/test_inheritance.py +++ b/ext/pybind11/tests/test_inheritance.py @@ -2,7 +2,7 @@ import pytest def test_inheritance(msg): - from pybind11_tests import Pet, Dog, Rabbit, Hamster, dog_bark, pet_name_species + from pybind11_tests import Pet, Dog, Rabbit, Hamster, Chimera, dog_bark, pet_name_species roger = Rabbit('Rabbit') assert roger.name() + " is a " + roger.species() == "Rabbit is a parrot" @@ -30,6 +30,10 @@ def test_inheritance(msg): Invoked with: <m.Pet object at 0> """ + with pytest.raises(TypeError) as excinfo: + Chimera("lion", "goat") + assert "No constructor defined!" in str(excinfo.value) + def test_automatic_upcasting(): from pybind11_tests import return_class_1, return_class_2, return_class_n, return_none @@ -37,7 +41,8 @@ def test_automatic_upcasting(): assert type(return_class_1()).__name__ == "DerivedClass1" assert type(return_class_2()).__name__ == "DerivedClass2" assert type(return_none()).__name__ == "NoneType" - # Repeat these a few times in a random order to ensure no invalid caching is applied + # Repeat these a few times in a random order to ensure no invalid caching + # is applied assert type(return_class_n(1)).__name__ == "DerivedClass1" assert type(return_class_n(2)).__name__ == "DerivedClass2" assert type(return_class_n(0)).__name__ == "BaseClass" @@ -53,3 +58,21 @@ def test_isinstance(): objects = [tuple(), dict(), Pet("Polly", "parrot")] + [Dog("Molly")] * 4 expected = (True, True, True, True, True, False, False) assert test_isinstance(objects) == expected + + +def test_holder(): + from pybind11_tests import test_mismatched_holder_type_1, test_mismatched_holder_type_2 + + with pytest.raises(RuntimeError) as excinfo: + test_mismatched_holder_type_1() + + assert str(excinfo.value) == ("generic_type: type \"MismatchDerived1\" does not have " + "a non-default holder type while its base " + "\"MismatchBase1\" does") + + with pytest.raises(RuntimeError) as excinfo: + test_mismatched_holder_type_2() + + assert str(excinfo.value) == ("generic_type: type \"MismatchDerived2\" has a " + "non-default holder type while its base " + "\"MismatchBase2\" does not") |