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

"N snapshots can be trimmed" but nothing is trimmed? #78

Open
pawamoy opened this issue Apr 30, 2024 · 3 comments
Open

"N snapshots can be trimmed" but nothing is trimmed? #78

pawamoy opened this issue Apr 30, 2024 · 3 comments

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Apr 30, 2024

When I run my test suite, I get this output at the end:

=============== inline snapshot ====================
Info: 11 snapshots can be trimmed (--inline-snapshot=trim)

From the docs:

trim removes every snapshots form the storage which is not referenced with external(...) in the code.

However if I run pytest with --inline-snapshot=trim it doesn't do anything. I have 11 external files indeed, so I suspect inline-snapshot doesn't detect external calls in my code:

snapshots = snapshot(
    {
        (
            ("annotations_path", "brief"),
            ("separate_signature", True),
            ("show_signature", False),
            ("show_signature_annotations", False),
            ("signature_crossrefs", False),
            ("unwrap_annotated", True),
        ): external("3603a08e7614*.html"),
        ...
    }
)
@pawamoy
Copy link
Contributor Author

pawamoy commented Apr 30, 2024

Can't reproduce while debugging. external calls are correctly identified. Maybe an issue with pytest-xdist again. UPDATE: yep, no such message when disabling pytest-xdist.

@pawamoy
Copy link
Contributor Author

pawamoy commented Apr 30, 2024

Quick thought: if inline-snapshot finds uses of external by searching in the files collected by the current pytest process, then it's possible that one of the process didn't run a single test from my module using external, and therefore inline-snapshot finds no reference to the existing snapshots. A solution would be to somehow check every test file used across the run (multiple process through xdist). Or maybe even all tests file, period, because if I unselect tests using external, that doesn't mean my snapshots are unused.

@15r10nk
Copy link
Owner

15r10nk commented May 7, 2024

0.9.0 contains now a check if you use xdist at the same time.

I think there are several issues with the current implementation of outsource. I have some ideas how the DX could be improved and wrote it down (#86). Please tell me if you have some feedback.

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