2from pybind11_tests
import ConstructorStats
3from pybind11_tests
import modules
as m
4from pybind11_tests.modules
import subsubmodule
as ms
10 assert pybind11_tests.__name__ ==
"pybind11_tests"
11 assert pybind11_tests.modules.__name__ ==
"pybind11_tests.modules"
13 pybind11_tests.modules.subsubmodule.__name__
14 ==
"pybind11_tests.modules.subsubmodule"
16 assert m.__name__ ==
"pybind11_tests.modules"
17 assert ms.__name__ ==
"pybind11_tests.modules.subsubmodule"
19 assert ms.submodule_func() ==
"submodule_func()"
24 assert str(b.get_a1()) ==
"A[1]"
25 assert str(b.a1) ==
"A[1]"
26 assert str(b.get_a2()) ==
"A[2]"
27 assert str(b.a2) ==
"A[2]"
31 assert str(b.get_a1()) ==
"A[42]"
32 assert str(b.a1) ==
"A[42]"
33 assert str(b.get_a2()) ==
"A[43]"
34 assert str(b.a2) ==
"A[43]"
37 assert astats.alive() == 2
38 assert bstats.alive() == 1
40 assert astats.alive() == 0
41 assert bstats.alive() == 0
42 assert astats.values() == [
"1",
"2",
"42",
"43"]
43 assert bstats.values() == []
44 assert astats.default_constructions == 0
45 assert bstats.default_constructions == 1
46 assert astats.copy_constructions == 0
47 assert bstats.copy_constructions == 0
50 assert astats.copy_assignments == 2
51 assert bstats.copy_assignments == 0
52 assert astats.move_assignments == 0
53 assert bstats.move_assignments == 0
57 from collections
import OrderedDict
59 from pybind11_tests.modules
import OD
61 assert OD
is OrderedDict
62 assert str(OD([(1,
"a"), (2,
"b")])) ==
"OrderedDict([(1, 'a'), (2, 'b')])"
66 """Pydoc needs to be able to provide help() for everything inside a pybind11 module"""
71 assert pybind11_tests.__name__ ==
"pybind11_tests"
72 assert pybind11_tests.__doc__ ==
"pybind11 test module"
73 assert pydoc.text.docmodule(pybind11_tests)
77 """Registering two things with the same name"""
79 assert m.duplicate_registration() == []
83 """Test that all the keys in the builtin modules have type str.
85 Previous versions of pybind11 would add a unicode key in python 2.
87 if hasattr(__builtins__,
"keys"):
88 keys = __builtins__.keys()
90 keys = __builtins__.__dict__.keys()
92 assert {
type(k)
for k
in keys} == {str}
static ConstructorStats & get(std::type_index type)
bool hasattr(handle obj, handle name)
def test_nested_modules()
def test_reference_internal()
def test_duplicate_registration()
def test_builtin_key_type()