Skip to content

Conversation

@nanxstats
Copy link
Collaborator

@nanxstats nanxstats commented Dec 27, 2025

Fixes #180

This PR migrates the R snapshot tests from the previous ad-hoc code extraction, snapshot saving, and comparison logic, to using the new package pytest-r-snapshot instead.

  • Switch RTF snapshot assertions to r_snapshot with semantic normalization.
  • Add missing R code chunk labels for footnote/source snapshots.
  • The snapshots are saved under the default location tests/__r_snapshots__/.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR successfully migrates the R snapshot testing infrastructure from a custom ad-hoc implementation to the standardized pytest-r-snapshot package, addressing issue #180. The migration eliminates manual fixture generation and comparison logic, replacing it with a cleaner, more maintainable approach.

Key changes:

  • Replaces custom ROutputReader class and fixture generation script with pytest-r-snapshot package
  • Consolidates RTF normalization logic into reusable normalize_rtf_semantic() function
  • Adds missing R code chunk labels for footnote and source snapshot tests

Reviewed changes

Copilot reviewed 36 out of 40 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uv.lock Adds pytest-r-snapshot==0.1.0 dependency with package metadata and hashes
pyproject.toml Includes pytest-r-snapshot>=0.1.0 in dev dependencies
.github/workflows/ci-tests.yml Installs pytest-r-snapshot in CI test workflows
.github/workflows/mkdocs.yml Installs pytest-r-snapshot in documentation build workflow
tests/utils.py Removes deprecated ROutputReader class (15 lines deleted)
tests/utils_snapshot.py Adds normalize_rtf_semantic() function to consolidate normalization steps; refactors assert_rtf_equals_semantic() to use it
tests/test_single_page_rtf.py Migrates 16 tests to use r_snapshot fixture with semantic normalization
tests/test_row.py Migrates 3 tests to use r_snapshot fixture
tests/test_pagination.py Migrates 1 test to use r_snapshot fixture
tests/test_input.py Migrates 5 tests to use r_snapshot fixture; adds R code chunk labels for footnote and source snapshot tests
tests/fixtures/run_r_tests.py Removes entire fixture generation script (127 lines)
tests/fixtures/README.md Removes fixture documentation (no longer needed)
tests/fixtures/r_outputs/* Removes old manually-generated snapshot files
tests/__r_snapshots__/**/*.rtf Adds new snapshot files generated by pytest-r-snapshot with updated font charset values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@elong0527 elong0527 merged commit 0b8dec2 into main Dec 27, 2025
9 checks passed
@nanxstats nanxstats deleted the pytest-r-snapshot branch December 27, 2025 23:55
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.

Migrate R snapshot tests to use pytest-r-snapshot

3 participants