add test for custom class name
This commit is contained in:
parent
cfb2b16288
commit
5a44ccb40c
|
@ -224,6 +224,7 @@ fn parse_attribute(attr: String) -> HashMap<&'static str, syn::Ident> {
|
|||
let mut params = HashMap::new();
|
||||
|
||||
if let Ok(tts) = syn::parse_token_trees(&attr) {
|
||||
let mut elem = Vec::new();
|
||||
let mut elems = Vec::new();
|
||||
|
||||
for tt in tts.iter() {
|
||||
|
@ -232,7 +233,6 @@ fn parse_attribute(attr: String) -> HashMap<&'static str, syn::Ident> {
|
|||
println!("Wrong format: {:?}", attr.to_string());
|
||||
}
|
||||
&syn::TokenTree::Delimited(ref delimited) => {
|
||||
let mut elem = Vec::new();
|
||||
for tt in delimited.tts.iter() {
|
||||
match tt {
|
||||
&syn::TokenTree::Token(syn::Token::Comma) => {
|
||||
|
@ -245,6 +245,9 @@ fn parse_attribute(attr: String) -> HashMap<&'static str, syn::Ident> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if !elem.is_empty() {
|
||||
elems.push(elem);
|
||||
}
|
||||
|
||||
for elem in elems {
|
||||
if elem.len() < 3 {
|
||||
|
|
|
@ -51,6 +51,18 @@ fn empty_class() {
|
|||
py_assert!(py, typeobj, "typeobj.__name__ == 'EmptyClass'");
|
||||
}
|
||||
|
||||
|
||||
#[py::class(name=CustomName)]
|
||||
struct EmptyClass2 { }
|
||||
|
||||
#[test]
|
||||
fn custom_class_name() {
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let typeobj = py.get_type::<EmptyClass2>();
|
||||
py_assert!(py, typeobj, "typeobj.__name__ == 'CustomName'");
|
||||
}
|
||||
|
||||
#[py::class]
|
||||
struct EmptyClassInModule { }
|
||||
|
||||
|
|
Loading…
Reference in New Issue