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

perf: only clear assertion _extension when overridden #172

Merged
merged 2 commits into from
Apr 3, 2020
Merged

Conversation

iamogbz
Copy link
Collaborator

@iamogbz iamogbz commented Apr 3, 2020

Description

  • Fixes an issue where the assertion _extension property cache is always cleared

Related Issues

N/A

Checklist

  • This PR has sufficient test coverage.
  • I will merge this pull request with a semantic title.

Additional Comments

  • Noticed warnings from the latest update

PytestDeprecationWarning: TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.
See https://docs.pytest.org/en/latest/deprecations.html#terminalreporter-writer for more information.
+ See pytest-dev/pytest#6936

@codecov
Copy link

codecov bot commented Apr 3, 2020

Codecov Report

Merging #172 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master   #172   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          16     16           
  Lines         859    864    +5     
=====================================
+ Hits          859    864    +5

@iamogbz iamogbz changed the title Fix warnings Do not clear _extension property when not overridden Apr 3, 2020
)
_executions: int = attr.ib(init=False, default=0)
_execution_results: Dict[int, "AssertionResult"] = attr.ib(init=False, factory=dict)
_post_assert_actions: List[Callable[..., None]] = attr.ib(init=False, factory=list)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could use a deque but that seems like premature optimisations

@iamogbz iamogbz requested a review from noahnu April 3, 2020 14:06
@iamogbz iamogbz marked this pull request as ready for review April 3, 2020 14:06
@iamogbz iamogbz changed the title Do not clear _extension property when not overridden perf: only clear assertion _extension when overridden Apr 3, 2020
@@ -51,5 +51,6 @@ def test_multiple_snapshot_extensions(snapshot):
"""
assert actual_svg == snapshot(extension_class=SVGImageSnapshotExtension)
assert actual_svg == snapshot # uses initial extension class
assert snapshot._extension is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is testing internals. Is there a user facing test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's no user effect only that slight performance drawback of generating the extension instance on each assertion

Copy link
Collaborator

Choose a reason for hiding this comment

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

Bit concerned about coupling the internal implementation with the test cases, but am okay with this as a temporary measure until we have perf benchmarking

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 thought we weren't using that deprecated method?

@iamogbz iamogbz merged commit 82eae91 into master Apr 3, 2020
@iamogbz iamogbz deleted the fix-warnings branch April 3, 2020 18:16
syrupy-bot pushed a commit that referenced this pull request Apr 3, 2020
## [0.3.8](v0.3.7...v0.3.8) (2020-04-03)

### Performance Improvements

* only clear assertion `_extension` when overridden ([#172](#172)) ([82eae91](82eae91))
@syrupy-bot
Copy link
Contributor

🎉 This PR is included in version 0.3.8 🎉

The release is available on GitHub release

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
Development

Successfully merging this pull request may close these issues.

3 participants