Skip to content

Commit

Permalink
Update test for sort_keys to also test tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Feb 6, 2025
1 parent 8586fe2 commit 8ddea90
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/unit/spec_tests/test_spec_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,19 @@ def test_sort_keys(self):
for attr in result['attributes']:
self.assertEqual(list(attr.keys()), ['name', 'dtype', 'doc'])

# Test tuple handling
input_tuple = (
{'doc': 'item1', 'name': 'name1', 'dtype': 'int'},
{'doc': 'item2', 'name': 'name2', 'dtype': 'float'}
)
result = writer.sort_keys(input_tuple)
# Convert generator to list for testing
result_list = list(result)
for item in result_list:
self.assertEqual(list(item.keys()), ['name', 'dtype', 'doc'])
# Verify the original order is maintained
self.assertEqual(result_list[0]['name'], 'name1')
self.assertEqual(result_list[1]['name'], 'name2')

class TestExportSpec(TestSpec):

Expand Down

0 comments on commit 8ddea90

Please sign in to comment.