syrusakbary / snapshottest

Snapshot Testing utils for Python 📸
MIT License
525 stars 102 forks source link

Generated tests are sorted out of order #148

Open datavistics opened 3 years ago

datavistics commented 3 years ago

generated snapshot: snapshots['test_foo 1'] = 'test'

snapshots['test_foo 10'] = 'test'

snapshots['test_foo 11'] = 'test' . . . snapshots['test_foo 2'] = 'test' . . .

Is there a way to get them to generate in numerical order?

paulmelnikow commented 3 years ago

Could you provide the test snippet that generates those snapshots?

datavistics commented 3 years ago

Sorry for the delay @paulmelnikow

def test_stuff(snapshot):
    for i in range(15):
        snapshot.assert_match(i)

Produces

# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import Snapshot

snapshots = Snapshot()

snapshots['test_stuff 1'] = 0

snapshots['test_stuff 10'] = 9

snapshots['test_stuff 11'] = 10

snapshots['test_stuff 12'] = 11

snapshots['test_stuff 13'] = 12

snapshots['test_stuff 14'] = 13

snapshots['test_stuff 15'] = 14

snapshots['test_stuff 2'] = 1

snapshots['test_stuff 3'] = 2

snapshots['test_stuff 4'] = 3

snapshots['test_stuff 5'] = 4

snapshots['test_stuff 6'] = 5

snapshots['test_stuff 7'] = 6

snapshots['test_stuff 8'] = 7

snapshots['test_stuff 9'] = 8