Skip to content

pytest fixtures: hg / git configurations to session scope #475

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

Merged
merged 10 commits into from
Oct 12, 2024
Merged

Conversation

tony
Copy link
Member

@tony tony commented Oct 12, 2024

Resolves #474

Problem

Issue #472 requires session-scoped fixtures.

Currently, we use set_home, gitconfig, and hgconfig to monkeypatch.setenv $HOME, pointing it to a temporary directory with user-specific configuration files. This ensures all subsequent git and hg commands automatically load these configurations.

However, monkeypatch.setenv doesn't work with function-scoped fixtures.

Improvement

❯ hyperfine \
  --warmup 3 \
  --runs 10 \
  --prepare 'git checkout master' \
  --command-name 'libvcs 0.31.0' \
  'py.test' \
  --prepare 'git checkout pytest-config' \
  --command-name 'with improved hg/git config fixtures' \
  'py.test'
Benchmark 1: libvcs 0.31.0
  Time (mean ± σ):     15.150 s ±  0.751 s    [User: 16.650 s, System: 4.720 s]
  Range (min … max):   14.235 s … 16.741 s    10 runs

Benchmark 2: with improved hg/git config fixtures
  Time (mean ± σ):     15.014 s ±  0.307 s    [User: 17.246 s, System: 4.865 s]
  Range (min … max):   14.458 s … 15.642 s    10 runs

Summary
  with improved hg/git config fixtures ran
    1.01 ± 0.05 times faster than libvcs 0.31.0

Changes

pytest fixtures: Session-scoped hgconfig and gitconfig

These are now set by set_hgconfig and set_gitconfig, which set HGRCPATH and GIT_CONFIG, instead of overriding HOME.

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.

Project coverage is 64.52%. Comparing base (58a9247) to head (43eebcb).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
src/libvcs/pytest_plugin.py 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #475      +/-   ##
==========================================
+ Coverage   64.17%   64.52%   +0.34%     
==========================================
  Files          40       40              
  Lines        3713     3721       +8     
  Branches      788      789       +1     
==========================================
+ Hits         2383     2401      +18     
+ Misses        793      782      -11     
- Partials      537      538       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tony tony force-pushed the pytest-config branch 3 times, most recently from a68d632 to 3e4d41e Compare October 12, 2024 22:00
tony added 3 commits October 12, 2024 17:08
Fixed 2 errors:
- src/libvcs/pytest_plugin.py:
    1 × RET504 (unnecessary-assign)
- tests/sync/test_svn.py:
    1 × COM812 (missing-trailing-comma)
@tony tony merged commit 7d6bc81 into master Oct 12, 2024
6 checks passed
@tony tony deleted the pytest-config branch October 12, 2024 22:14
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.

Commands: Set configuration file (for tests)
1 participant