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

feat(amber): change serialization to be py syntax like #505

Merged
merged 1 commit into from
Oct 31, 2021

Conversation

iamogbz
Copy link
Collaborator

@iamogbz iamogbz commented May 30, 2021

Description

  • This changes the default amber serialization to better match python syntax. This does NOT need the file to be python parseable, just leverages python syntax recognition to make snapshots easier to grok.
  • Enforces keyword arguments in filter and matcher factory functions

Example

  • VSCode Python Language Mode
    "files.associations": {
        "*.ambr": "python",
    },

https://github.com/tophat/syrupy/blob/aa46082894e3bb646d789a6f9c09c059d80dcd18/tests/syrupy/extensions/amber/__snapshots__/test_amber_serializer.ambr#L49-L83

Related Issues

Checklist

  • This PR has sufficient documentation.
  • This PR has sufficient test coverage.
  • This PR title satisfies semantic convention.

Additional Comments

BREAKING CHANGE: update to serialization requires regeneration of snapshots

Migration Guide

  • pytest --snapshot-update to regenerate amber snapshots

@iamogbz iamogbz requested a review from noahnu May 30, 2021 18:39
Base automatically changed from fix-black-linting to master May 30, 2021 20:14
@iamogbz iamogbz force-pushed the format-ambr-py-like branch 3 times, most recently from 3c560c3 to 4c19cee Compare June 1, 2021 06:41
Copy link
Collaborator

@noahnu noahnu left a comment

Choose a reason for hiding this comment

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

I agree this looks nicer. I do think we should keep the initial indent though.

src/syrupy/extensions/amber/serializer.py Outdated Show resolved Hide resolved
src/syrupy/filters.py Outdated Show resolved Hide resolved
@iamogbz iamogbz force-pushed the format-ambr-py-like branch 2 times, most recently from 7417e1b to 1d9665a Compare June 1, 2021 19:34
conftest.py Outdated Show resolved Hide resolved
@iamogbz iamogbz force-pushed the format-ambr-py-like branch 2 times, most recently from aa46082 to 0a12e70 Compare June 5, 2021 19:33
@iamogbz iamogbz requested a review from noahnu June 5, 2021 20:22
@iamogbz iamogbz force-pushed the format-ambr-py-like branch 4 times, most recently from 3de6031 to cb9819c Compare June 12, 2021 08:15
@iamogbz iamogbz force-pushed the format-ambr-py-like branch from cb9819c to 8f34d16 Compare June 13, 2021 19:32
@codecov
Copy link

codecov bot commented Jun 13, 2021

Codecov Report

Merging #505 (e39a738) into next (21cfed8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             next     #505   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files          19       19           
  Lines        1130     1132    +2     
=======================================
+ Hits         1129     1131    +2     
  Misses          1        1           

@iamogbz iamogbz force-pushed the format-ambr-py-like branch from 8f34d16 to 6652cc4 Compare June 14, 2021 22:03
BREAKING CHANGE: update to serialization requires regeneration of snapshots

Migration Guide
* `pytest --snapshot-update` to regenerate amber snapshots
@iamogbz iamogbz force-pushed the format-ambr-py-like branch from 6652cc4 to e39a738 Compare October 31, 2021 00:51
@iamogbz iamogbz changed the base branch from master to next October 31, 2021 00:51
@iamogbz iamogbz marked this pull request as ready for review October 31, 2021 00:51
Comment on lines -202 to -210
open_paren, close_paren = next(
parens
for iter_type, parens in {
GeneratorType: ("(", ")"),
list: ("[", "]"),
tuple: ("(", ")"),
}.items()
if isinstance(data, iter_type)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for dropping round brackets for the tuples?

@iamogbz iamogbz merged commit a860c0a into next Oct 31, 2021
@iamogbz iamogbz deleted the format-ambr-py-like branch October 31, 2021 01:07
noahnu pushed a commit that referenced this pull request Feb 20, 2022
BREAKING CHANGE: update to serialization requires regeneration of snapshots

Migration Guide
* `pytest --snapshot-update` to regenerate amber snapshots
@noahnu noahnu mentioned this pull request Feb 20, 2022
3 tasks
tophat-opensource-bot pushed a commit that referenced this pull request Apr 10, 2022
# [2.0.0](v1.7.4...v2.0.0) (2022-04-10)

### Features

* **amber:** change serialization to be py syntax like ([#505](#505)) ([b64b965](b64b965))
* release syrupy v2 ([#575](#575)) ([bc8b3a9](bc8b3a9))

### BREAKING CHANGES

* **amber:** update to serialization requires regeneration of snapshots

Migration Guide
* `pytest --snapshot-update` to regenerate amber snapshots
RobertCraigie added a commit to RobertCraigie/prisma-client-py that referenced this pull request Oct 29, 2022
RobertCraigie added a commit to RobertCraigie/prisma-client-py that referenced this pull request Oct 29, 2022
…ts (#535)

* chore(deps): bump syrupy from 1.5.0 to 3.0.2 in /pipelines/requirements

Bumps [syrupy](https://github.com/tophat/syrupy) from 1.5.0 to 3.0.2.
- [Release notes](https://github.com/tophat/syrupy/releases)
- [Changelog](https://github.com/tophat/syrupy/blob/master/CHANGELOG.md)
- [Commits](syrupy-project/syrupy@v1.5.0...v3.0.2)

---
updated-dependencies:
- dependency-name: syrupy
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update snapshots per syrupy breaking change

syrupy-project/syrupy#505

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Craigie <robert@craigie.dev>
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.

How to improve a large snapshot instance and make it more readable
2 participants