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

refactor: optimise session data structures #403

Merged
merged 3 commits into from
Oct 30, 2020

Conversation

iamogbz
Copy link
Collaborator

@iamogbz iamogbz commented Oct 30, 2020

Description

  • Removes unnecessary use of dict in the session/report for tracking all test items
  • Renames ran items to selected items, just more semantically accurate
  • Move test collection logic into the session instance

Checklist

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

Additional Comments

No additional comments.

@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #403 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1001      1023   +22     
=========================================
+ Hits          1001      1023   +22     

src/syrupy/session.py Outdated Show resolved Hide resolved
@iamogbz iamogbz requested a review from noahnu October 30, 2020 16:08
Comment on lines -31 to +34
_all_items: Dict["pytest.Item", bool] = attr.ib(factory=dict)
_collected_items: Set["pytest.Item"] = attr.ib(factory=set)
# All the selected test items. Will be set to False until the test item is run.
_ran_items: Dict["pytest.Item", bool] = attr.ib(factory=dict)
_selected_items: Dict[str, bool] = attr.ib(factory=dict)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This assumes that collected items are a superset of selected items, hence no need to duplicate the references. And using the node ids to save run state, allows easy lookup inran_item(...) usage.

Comment on lines +66 to +68
_collected_items_by_nodeid: Dict[str, "pytest.Item"] = attr.ib(
factory=dict, init=False
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is generated once at instantiation, and used to easily map selected item nodes to collected pytest items.

@iamogbz iamogbz merged commit 818d405 into master Oct 30, 2020
@iamogbz iamogbz deleted the refactor-optimise-session-data branch October 30, 2020 20:03
syrupy-bot pushed a commit that referenced this pull request Oct 30, 2020
## [0.8.4](v0.8.3...v0.8.4) (2020-10-30)

### Performance Improvements

* optimise session items data structures ([#403](#403)) ([818d405](818d405))
@syrupy-bot
Copy link
Contributor

🎉 This PR is included in version 0.8.4 🎉

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