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

once fixtures don't get Dropped #132

Closed
vpzomtrrfrt opened this issue Jan 5, 2022 · 3 comments
Closed

once fixtures don't get Dropped #132

vpzomtrrfrt opened this issue Jan 5, 2022 · 3 comments

Comments

@vpzomtrrfrt
Copy link

Example:

use rstest::*;

struct SomeStruct {}
impl std::ops::Drop for SomeStruct {
    fn drop(&mut self) {
        std::fs::File::create("got_dropped").unwrap();
    }
}

#[fixture]
#[once]
fn value() -> SomeStruct {
    std::fs::File::create("got_created").unwrap();
    SomeStruct {}
}

#[rstest]
fn test1(value: &SomeStruct) {
    assert!(true);
}

Running this test creates the "got_created" file but not the "got_dropped" file, indicating that the Drop implementation for SomeStruct was not run

@la10736
Copy link
Owner

la10736 commented Jan 5, 2022

I'm sorry, but this is a well know limitation of this implementation (#119 (comment)). You can find a note about this at https://docs.rs/rstest/latest/rstest/attr.fixture.html#once-fixture .
I think that there is no way to implement it without write a custom test runner that will make this crate harder to use.

@vpzomtrrfrt
Copy link
Author

ah I missed that note, fair enough

@vpzomtrrfrt
Copy link
Author

Might be worth adding to the readme though

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