Lines Matching defs:module
54 auto module = py::module::import("test_interpreter");
55 REQUIRE(py::hasattr(module, "DerivedWidget"));
57 auto locals = py::dict("hello"_a="Hello, World!", "x"_a=5, **module.attr("__dict__"));
64 auto py_widget = module.attr("DerivedWidget")("The question");
73 REQUIRE_NOTHROW(py::module::import("widget_module"));
74 REQUIRE_THROWS_WITH(py::module::import("throw_exception"),
76 REQUIRE_THROWS_WITH(py::module::import("throw_error_already_set"),
110 REQUIRE(py::module::import("widget_module").attr("add")(1, 2).cast<int>() == 3);
113 REQUIRE(py::module::import("external_module").attr("A")(123).attr("value").cast<int>() == 123);
115 // local and foreign module internals should point to the same internals:
117 py::module::import("external_module").attr("internals_at")().cast<uintptr_t>());
133 py::module::import("external_module").attr("internals_at")().cast<uintptr_t>());
140 py::module::import("__main__").attr("internals_destroy_test") =
152 auto cpp_module = py::module::import("widget_module");
156 auto py_module = py::module::import("test_interpreter");
163 py::module::import("__main__").attr("main_tag") = "main interpreter";
165 auto m = py::module::import("widget_module");
166 m.attr("extension_module_tag") = "added to module in main interpreter";
184 REQUIRE_FALSE(py::hasattr(py::module::import("__main__"), "tag"));
186 auto m = py::module::import("widget_module");
197 REQUIRE(py::hasattr(py::module::import("__main__"), "main_tag"));
198 REQUIRE(py::hasattr(py::module::import("widget_module"), "extension_module_tag"));
244 TEST_CASE("Reload module from file") {
248 auto sys = py::module::import("sys");
259 // Create the module .py file
269 // Import the module from file
270 auto module = py::module::import(module_name.c_str());
271 int result = module.attr("test")().cast<int>();
274 // Update the module .py file with a small change
280 // Reload the module
281 module.reload();
282 result = module.attr("test")().cast<int>();