File: test_macro_docs.rs

package info (click to toggle)
rust-pyo3 0.22.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,420 kB
  • sloc: makefile: 58; python: 39; sh: 1
file content (38 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![cfg(feature = "macros")]

use pyo3::prelude::*;
use pyo3::types::IntoPyDict;

#[macro_use]
#[path = "../src/tests/common.rs"]
mod common;

#[pyclass]
/// The MacroDocs class.
#[doc = concat!("Some macro ", "class ", "docs.")]
/// A very interesting type!
struct MacroDocs {}

#[pymethods]
impl MacroDocs {
    #[doc = concat!("A macro ", "example.")]
    /// With mixed doc types.
    fn macro_doc(&self) {}
}

#[test]
fn meth_doc() {
    Python::with_gil(|py| {
        let d = [("C", py.get_type_bound::<MacroDocs>())].into_py_dict_bound(py);
        py_assert!(
            py,
            *d,
            "C.__doc__ == 'The MacroDocs class.\\nSome macro class docs.\\nA very interesting type!'"
        );
        py_assert!(
            py,
            *d,
            "C.macro_doc.__doc__ == 'A macro example.\\nWith mixed doc types.'"
        );
    });
}