Skip to content

Commit

Permalink
#160 Don't warning if names contains no snake
Browse files Browse the repository at this point in the history
case.
  • Loading branch information
la10736 committed Nov 27, 2022
1 parent cb782b2 commit 6fd8e72
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -5,8 +5,8 @@

### Changed

- Now we show `TEST START` banner only when trace some argument: See #158 for details.
- Now we try to add the values to test name: See #160 for details.
- Show `TEST START` banner only when trace some argument: See #158 for details.
- Add values to test name: See #160 for details.

### Fixed

Expand Down
21 changes: 21 additions & 0 deletions rstest/tests/resources/rstest/values_tests_name.rs
@@ -0,0 +1,21 @@
use rstest::*;

enum Application {
Python,
Node,
Go,
}

enum Method {
GET,
POST,
PUT,
HEAD,
}

#[rstest]
fn name_values(
#[values(Application::Python, Application::Node, Application::Go)] _val: Application,
#[values(Method::GET, Method::POST, Method::PUT, Method::HEAD)] _method: Method,
) {
}
7 changes: 7 additions & 0 deletions rstest/tests/rstest/mod.rs
Expand Up @@ -66,6 +66,13 @@ fn should_not_show_a_warning_for_should_panic_attribute() {
assert!(!output.stderr.str().contains("unused attribute"));
}

#[test]
fn should_not_show_a_warning_for_values_test_names() {
let (output, _) = run_test("values_tests_name.rs");

assert_not_in!(output.stderr.str(), "warning:");
}

#[test]
fn should_map_fixture_by_remove_first_underscore_if_any() {
let (output, _) = run_test("remove_underscore.rs");
Expand Down
11 changes: 9 additions & 2 deletions rstest_macros/src/render/mod.rs
Expand Up @@ -120,15 +120,22 @@ fn _matrix_recursive<'a>(
let list_values = &list_values[1..];

if list_values.is_empty() {
vlist.render(test, resolver, attrs, attributes)
let mut attrs = attrs.to_vec();
attrs.push(parse_quote!(
#[allow(non_snake_case)]
));
vlist.render(test, resolver, &attrs, attributes)
} else {
let span = test.sig.ident.span();
let modules = vlist.argument_data(resolver).map(move |(name, resolver)| {
_matrix_recursive(test, list_values, &resolver, attrs, attributes)
.wrap_by_mod(&Ident::new(&name, span))
});

quote! { #(#modules)* }
quote! { #(
#[allow(non_snake_case)]
#modules
)* }
}
}

Expand Down

0 comments on commit 6fd8e72

Please sign in to comment.