-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: remove unused snapshots in snapshot file #11
Conversation
@@ -25,24 +25,34 @@ def __init__( | |||
self._serializer_class = serializer_class | |||
self._test_location = test_location | |||
self._executions = 0 | |||
self._session = session | |||
|
|||
from .session import SnapshotSession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to refactor so we don't have to import within the method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so but the refactor is quite extensive and not valuable imo since the only usecase here was for the type hinting.
|
||
def _in_snapshot_dir(self, path: str) -> bool: | ||
parts = path.split(os.path.sep) | ||
return SNAPSHOT_DIRNAME in parts | ||
|
||
@lru_cache(maxsize=32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you notice a performance issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, but I didn't see any reason why it should be executed every single time an assertion was registered. Might be a bit premature...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR LGTM
When testing this locally I noticed unused snapshots -- so it works but we should still remove these snapshots before merging this. I also have .githooks.ini modified locally for some reason after running the linter. |
for some reason it keeps adding it
DevQA
inv test
should show unused snapshots in single fileassert actual == snapshot_png
line in the image plugin testhttps://github.com/tophat/syrupy/blob/1ad07661f3842557d1553c74f6b7976a7f8d81ef/tests/test_image_plugin.py#L22
inv test
should show that the image file is also unusedinv test -u
should update the snapshot files and remove the image snapshot fileinv test
should show no snapshot file is unusedtest_snapshot.py
fileinv test -u
should delete thetest_snapshot.yaml
fileComments