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

Snapshots of parameterized tests save in alphabetical order instead of declared order #968

Open
james-seymour-cubiko opened this issue Mar 20, 2025 · 0 comments
Labels
feature request New feature or request
Milestone

Comments

@james-seymour-cubiko
Copy link

When using @pytest.mark.parametrize with the ids argument, snapshots are saved in alphabetical order of ids instead of in the declared order. This makes snapshots harder to read, especially when there are many parametrisations and they are in some logical order (e.g. from simple to complex)

To reproduce

With a simple parameterised test setup such as

@pytest.mark.parametrize(
    argnames=("input"),
    argvalues=[
        ("test_b"),
        ("test_a"),
    ],
    ids=["b", "a"],
)
def test_input(input: str, snapshot: SnapshotAssertion):
    assert input == snapshot

syrupy will save the snapshots for these tests as

# name: test_input[a]
  'test_a'
# ---
# name: test_input[b]
  'test_b'
# ---

Expected behavior

I would expect that syrupy should save the snapshots for these tests as

# name: test_input[b]
  'test_b'
# ---
# name: test_input[a]
  'test_a'
# ---

Should this be the intended behaviour? If so, I'm happy to do the PR :)

Environment (please complete the following information):

  • OS: Fedora 40
  • Syrupy Version: 4.8.2
  • Python Version: 3.12.9
@noahnu noahnu added the feature request New feature or request label Mar 20, 2025
@noahnu noahnu added this to the syrupy/5.0.0 milestone Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants