Skip to content

Commit

Permalink
Merge pull request #244 from narpfel/no-rstest_reuse-in-crate-root
Browse files Browse the repository at this point in the history
No longer require `rstest_reuse` to be imported explicitly into the crate root
  • Loading branch information
la10736 committed Apr 21, 2024
2 parents 06a2117 + 91e70e9 commit 8eec79d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rstest_reuse/src/lib.rs
Expand Up @@ -360,7 +360,7 @@ pub fn template(_args: proc_macro::TokenStream, input: proc_macro::TokenStream)
#macro_attribute
macro_rules! #macro_name_rand {
( $test:item ) => {
$crate::rstest_reuse::merge_attrs! {
::rstest_reuse::merge_attrs! {
#template,
$test
}
Expand Down
9 changes: 9 additions & 0 deletions rstest_reuse/tests/acceptance.rs
Expand Up @@ -183,6 +183,15 @@ fn should_export_main_root() {
TestResults::new().ok("test::case_1").assert(output);
}

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

TestResults::new()
.ok("test::case_1")
.assert(output);
}

lazy_static! {
static ref ROOT_DIR: TempDir = TempDir::new(std::env::temp_dir().join("rstest_reuse"), false);
static ref ROOT_PROJECT: Project = Project::new(ROOT_DIR.as_ref());
Expand Down
13 changes: 13 additions & 0 deletions rstest_reuse/tests/resources/rstest_reuse_not_in_crate_root.rs
@@ -0,0 +1,13 @@
use rstest::rstest;
use rstest_reuse::apply;
use rstest_reuse::template;

#[template]
#[rstest]
#[case(42)]
fn test_template(#[case] n: u32) {}

#[apply(test_template)]
fn test(#[case] n: u32) {
assert_eq!(n, 42);
}
2 changes: 1 addition & 1 deletion rstest_reuse/tests/resources/simple_example.rs
@@ -1,5 +1,5 @@
use rstest::rstest;
use rstest_reuse::{self, *};
use rstest_reuse::*;

#[template]
#[rstest(a, b, case(2, 2), case(4/2, 2))]
Expand Down

0 comments on commit 8eec79d

Please sign in to comment.