Skip to content

Switch all regression tests to syrupy #1152

@ns-rse

Description

@ns-rse

Further to #1143 which has been (or will be) closed by changes in #1151 I think we should consider looking at switching all of our tests from pytest-regtest to syrupy.

Bit of a chore but will hopefully give finer grained insight onto difference in data frames and dictionaries (you can see an example of comparing dictionaries in the syrupy video.

The code for doing so is I feel easier to understand...

    def test_syrupy(snapshot):
    assert "something" == snapshot

On first running this will fail because no snapshot exists so you have to run...

pytest --snapshot-update

This creates a directory __snapshot__ which contains a file for each test that uses snapshots (remember to include these in the git commit and remove the related file under tests/_regtest_outputs when switching).

We can see which files need updating by looking in tests/_regtest_outputs...

❱ l tests/_regtest_outputs 
drwxr-xr-x neil neil 4.0 KB Tue Apr 29 15:26:46 2025  .
drwxr-xr-x neil neil 4.0 KB Fri May  9 10:35:03 2025  ..
.rw-r--r-- neil neil 1.4 KB Wed Apr  9 10:40:12 2025  test_grainstats_minicircle.test_grainstats_regression.out
.rw-r--r-- neil neil 560 B  Wed Oct  4 14:26:12 2023  test_plotting.test_computeStats.out
.rw-r--r-- neil neil 2.9 KB Tue Apr 29 15:26:46 2025  test_processing.test_process_scan_above.out
.rw-r--r-- neil neil 1.4 KB Mon Dec 16 15:53:46 2024  test_processing.test_process_scan_above_height_profiles.out
.rw-r--r-- neil neil 1.3 KB Wed Apr 23 09:41:52 2025  test_processing.test_process_scan_below.out
.rw-r--r-- neil neil 254 B  Mon Dec 16 15:53:46 2024  test_processing.test_process_scan_below_height_profiles.out
.rw-r--r-- neil neil 3.0 KB Tue Apr 29 15:26:46 2025  test_processing.test_process_scan_both.out

Thus the files/tests that need updating are...

  • test_grainstats_minicircle.py::test_grainstats_regression
  • test_plotting.py::test_computeStats
  • test_processing.py::test_process_scan_above
  • test_processing.py::test_process_scan_above_height_profiles
  • test_processing.py::test_process_scan_below
  • test_processing.py::test_process_scan_below_height_profiles
  • test_processing.py::test_process_scan_both

Metadata

Metadata

Assignees

Labels

testsIssues pertaining to testing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions