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

Graduate Syrupy v4 pre-release #605

Merged
merged 15 commits into from
Feb 2, 2023
Merged

Graduate Syrupy v4 pre-release #605

merged 15 commits into from
Feb 2, 2023

Conversation

noahnu
Copy link
Collaborator

@noahnu noahnu commented May 28, 2022

Changes

Performance

  • Writes no longer occur at assertion time, but are instead queued to happen at the end of the pytest session. This defers IO operations to the end of the test run, however it does increase memory usage. If this presents an issue, we can look at providing an opt-out mechanism for deferred writes. This should also improve pytest-xdist compatibility somewhat.

Breaking Changes

Requirements

  • Min. python version updated to 3.8.1. Since it's possible not everyone will be able to upgrade to Syrupy v4 because of the increase minimum python version, we will consider backporting critical bugs and security vulnerabilities on request (create a GitHub issue).
  • Min. pytest version updated to 7.0.0.

Bug Fixes

Serializers

Extensions API

  • For developers of custom Syrupy extensions, there are a number of changes to the public API of the various extension abstract classes:
    • pre/post read/write hooks have been removed. If you were using these hooks, please open a GitHub issue and we'll consider re-adding them (they had little usage and introduced maintenance complexity).
    • test_location is no longer passed to the constructor of extensions. Instead, it is now an explicit argument of most extension methods.
    • file_extension is now a class property rather than a property instance method.
    • dirname and various other filename related properties have been converted to class methods.
    • Renamed DataSerializer to AmberDataSerializer.
    • Serializers may now throw a TaintedSnapshotError which will tell the user to regenerate the snapshot even if the underlying data has not changed. This is to support rolling out more subtle changes to the serializers, such as the introduction of serializer metadata.

@codecov
Copy link

codecov bot commented May 28, 2022

Codecov Report

Merging #605 (6385979) into main (02abef5) will decrease coverage by 1.25%.
The diff coverage is 94.69%.

@@            Coverage Diff             @@
##             main     #605      +/-   ##
==========================================
- Coverage   99.54%   98.29%   -1.25%     
==========================================
  Files          20       20              
  Lines        1326     1410      +84     
==========================================
+ Hits         1320     1386      +66     
- Misses          6       24      +18     

@noahnu noahnu changed the title Graduate Syrupy v3 pre-release Graduate Syrupy v4 pre-release Aug 11, 2022
@noahnu noahnu force-pushed the next branch 3 times, most recently from 5d8631e to 34d9871 Compare August 11, 2022 21:28
@noahnu noahnu added this to the v4.0.0 - Performance milestone Aug 18, 2022
@noahnu noahnu force-pushed the next branch 5 times, most recently from 6d17701 to 3279e90 Compare November 8, 2022 23:11
noahnu and others added 7 commits December 30, 2022 13:26
* fix: group snapshot writes by extension class

* refactor: rename PyTestLocation.filename to .basename

BREAKING CHANGE: PyTestLocation.filename has been renamed to .basename

* refactor: add test_location kwarg to get_snapshot_name

* refactor: get_snapshot_name is now static as a classmethod

* refactor: remove pre and post read/write hooks

BREAKING CHANGE: Pre and post read/write hooks have been removed without replacement to make internal refactor simpler. Please open a GitHub issue if you have a use case for these hooks.

* refactor: rename Fossil to Collection

BREAKING CHANGE: The term 'fossil' has been replaced by the clearer term 'collection'.

* refactor: pass test_location to read_snapshot

* refactor: remove singular write_snapshot method

* refactor: dirname property to method

* refactor: pass test_location to discover_snapshots

* refactor: remove usage of self.test_location

* refactor: make write_snapshot a classmethod

* refactor: do not instantiate extension with test_location

BREAKING CHANGE: Numerous instance methods have been refactored as classmethods.
BREAKING CHANGE: Raise minimum python version to 3.8.1 and min. pytest version to v7.
NOTE: When pytest-xdist is detected, we do not remove unused snapshots, since that requires coordination between the workers and the controller. A disclaimer has been added to the README and TODO comments added to the source code to help solve this problem at some point.
Noah Negin-Ulster and others added 2 commits December 30, 2022 13:36
BREAKING CHANGE: The JSONSnapshotExtension now serializes Python's None as "null" rather than "None".
@noahnu noahnu linked an issue Dec 30, 2022 that may be closed by this pull request
Noah Negin-Ulster and others added 4 commits December 30, 2022 14:21
BREAKING CHANGE: Key order is now preserved if using OrderedDict in both the Amber serializer and JSON serializer.
* refactor: simplify data serializer for ambr

* feat: introduce concept of a tainted snapshot

BREAKING CHANGE: Serializers may now throw a TaintedSnapshotError which will tell the user to regenerate the snapshot even if the underlying data has not changed. This is to support rolling out more subtle changes to the serializers, such as the introduction of serializer metadata.

BREAKING CHANGE: Renamed DataSerializer to AmberDataSerializer.
@noahnu noahnu marked this pull request as ready for review February 2, 2023 18:48
@noahnu noahnu merged commit 5eee3d8 into main Feb 2, 2023
@tophat-opensource-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants