MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / empty_class_in_module

Function empty_class_in_module

tests/test_class.rs:52–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51#[test]
52fn empty_class_in_module() {
53 let gil = Python::acquire_gil();
54 let py = gil.python();
55 let module = PyModule::new(py, "test_module.nested").unwrap();
56 module.add_class::<EmptyClassInModule>(py).unwrap();
57
58 let ty = module.get(py, "EmptyClassInModule").unwrap();
59 assert_eq!(
60 ty.getattr(py, "__name__")
61 .unwrap()
62 .extract::<String>(py)
63 .unwrap(),
64 "EmptyClassInModule"
65 );
66 assert_eq!(
67 ty.getattr(py, "__module__")
68 .unwrap()
69 .extract::<String>(py)
70 .unwrap(),
71 "test_module.nested"
72 );
73}
74
75py_class!(class EmptyClassWithNew |py| {
76 def __new__(_cls) -> PyResult<EmptyClassWithNew> {

Callers

nothing calls this directly

Calls 2

pythonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected