summaryrefslogtreecommitdiff
path: root/ext/pybind11/tests/test_modules.py
diff options
context:
space:
mode:
authorJason Lowe-Power <jason@lowepower.com>2017-11-17 17:02:05 -0800
committerJason Lowe-Power <jason@lowepower.com>2017-12-14 00:27:59 +0000
commitf07d5069d86e31ecf195664850f79fb00c445bd3 (patch)
treef54ac06896fa828f873d199a0e9b25bd94911c79 /ext/pybind11/tests/test_modules.py
parent3f64b374c49491f18dc2ca538ed8c8597e4aac83 (diff)
downloadgem5-f07d5069d86e31ecf195664850f79fb00c445bd3.tar.xz
ext: Upgrade PyBind11 to version 2.2.1
This upgrade is necessary for pybind to build with GCC 7.2. We still need to add the patch for stl.h. MSC_FULL_VER change is no longer needed. See https://gem5-review.googlesource.com/c/public/gem5/+/2230 Change-Id: I806729217d022070583994c2dfcaa74476aef30f Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/5801 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'ext/pybind11/tests/test_modules.py')
-rw-r--r--ext/pybind11/tests/test_modules.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/ext/pybind11/tests/test_modules.py b/ext/pybind11/tests/test_modules.py
index 69620949b..2552838c2 100644
--- a/ext/pybind11/tests/test_modules.py
+++ b/ext/pybind11/tests/test_modules.py
@@ -1,32 +1,34 @@
+from pybind11_tests import modules as m
+from pybind11_tests.modules import subsubmodule as ms
+from pybind11_tests import ConstructorStats
+
def test_nested_modules():
import pybind11_tests
- from pybind11_tests.submodule import submodule_func
-
assert pybind11_tests.__name__ == "pybind11_tests"
- assert pybind11_tests.submodule.__name__ == "pybind11_tests.submodule"
+ assert pybind11_tests.modules.__name__ == "pybind11_tests.modules"
+ assert pybind11_tests.modules.subsubmodule.__name__ == "pybind11_tests.modules.subsubmodule"
+ assert m.__name__ == "pybind11_tests.modules"
+ assert ms.__name__ == "pybind11_tests.modules.subsubmodule"
- assert submodule_func() == "submodule_func()"
+ assert ms.submodule_func() == "submodule_func()"
def test_reference_internal():
- from pybind11_tests import ConstructorStats
- from pybind11_tests.submodule import A, B
-
- b = B()
+ b = ms.B()
assert str(b.get_a1()) == "A[1]"
assert str(b.a1) == "A[1]"
assert str(b.get_a2()) == "A[2]"
assert str(b.a2) == "A[2]"
- b.a1 = A(42)
- b.a2 = A(43)
+ b.a1 = ms.A(42)
+ b.a2 = ms.A(43)
assert str(b.get_a1()) == "A[42]"
assert str(b.a1) == "A[42]"
assert str(b.get_a2()) == "A[43]"
assert str(b.a2) == "A[43]"
- astats, bstats = ConstructorStats.get(A), ConstructorStats.get(B)
+ astats, bstats = ConstructorStats.get(ms.A), ConstructorStats.get(ms.B)
assert astats.alive() == 2
assert bstats.alive() == 1
del b
@@ -47,7 +49,7 @@ def test_reference_internal():
def test_importing():
- from pybind11_tests import OD
+ from pybind11_tests.modules import OD
from collections import OrderedDict
assert OD is OrderedDict
@@ -59,4 +61,12 @@ def test_pydoc():
import pybind11_tests
import pydoc
+ assert pybind11_tests.__name__ == "pybind11_tests"
+ assert pybind11_tests.__doc__ == "pybind11 test module"
assert pydoc.text.docmodule(pybind11_tests)
+
+
+def test_duplicate_registration():
+ """Registering two things with the same name"""
+
+ assert m.duplicate_registration() == []