Skip to content

Add fixtures cache and Telescope picker for ambiguous fixtures#10

Open
Nosterx wants to merge 5 commits intoAckslD:mainfrom
Nosterx:main
Open

Add fixtures cache and Telescope picker for ambiguous fixtures#10
Nosterx wants to merge 5 commits intoAckslD:mainfrom
Nosterx:main

Conversation

@Nosterx
Copy link

@Nosterx Nosterx commented Feb 15, 2025

This pull request introduces the following changes:

Fixture Caching:
  • Adds a cache for fixture information to avoid delays on the pytest --fixture -v command, which can take several seconds (up to six seconds in my experience) in large codebases.
  • Implements autocmd to populate the cache automatically when Python test files are entered, written, or read.
Handling Ambiguous Fixtures:
  • When multiple fixtures with the same name are defined in different locations, opens a Telescope file chooser with preview to allow the user to select the desired file.
  • According to pytest-dev/pytest#3966, resolving the correct fixture location is challenging even for pytest itself.

…ommand that warms up the cache upon entering a test file.
@arturbalabanov
Copy link

Just discovered this plugin (awesome work @AckslD!) and ran into the same annoyance. Was going to implement caching and then saw this PR -- works great, thank you @Nosterx!

if not settings.settings.no_commands then
setup_commands()
end
create_autocmd()
Copy link
Owner

@AckslD AckslD Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could at least be opt-out? Same as the commands above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I've added a configuration option to enable/disable the auto-commands feature. If auto-commands are disabled, the fixture cache will still be populated when the to_declaration method is called. Let me know if you have any further feedback! 😊

@AckslD
Copy link
Owner

AckslD commented Mar 12, 2025

@Nosterx! This looks great, nice work! Also thanks for submitting a clean PR :) I just have one question above, otherwise happy to merge.

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

Successfully merging this pull request may close these issues.

3 participants