Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destructure fixture type in template #273

Open
SET001 opened this issue Sep 4, 2024 · 1 comment
Open

destructure fixture type in template #273

SET001 opened this issue Sep 4, 2024 · 1 comment

Comments

@SET001
Copy link

SET001 commented Sep 4, 2024

There is #[from(...)] attribute to destructure fixture type. Should it work with rstest_reuse? If yes then how?
Here is my attempt and it does not work

fn foo() -> (usize, usize) {
  (1, 1)
}

#[template]
#[rstest]
#[case(foo(), 0, 1)]
fn remove_test_cases(
  #[case] input: (usize, usize),
  #[case] to_remove: usize,
  #[case] expect: usize,
) {}

#[apply(remove_test_cases)]
fn when_component_removed(
  #[from(input)] (one, two): (usize, usize),
  to_remove: usize,
  expect: usize,
) {}

the error is

Wrong case signature: should match the given parameters list.
@la10736
Copy link
Owner

la10736 commented Sep 4, 2024

I'm sorry. In rstest_rreuse destruct support is not implemented yet.

Just as note, the relevant code to change is

if let syn::FnArg::Typed(a) = arg {
if let syn::Pat::Ident(ref id) = *a.pat {
if let Some(source_arg) = resolve_template_arg(&to_merge_args, &id.ident) {
merge_arg_attributes(&mut a.attrs, &source_arg.attrs);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants