Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class DecimalPrimaryKey(dj.Lookup):
definition = """
id : decimal(4,3)
"""
contents = zip((0.1, 0.25, 3.99))
contents = list(zip((0.1, 0.25, 3.99)))
Copy link
Contributor Author

@ethho ethho Dec 13, 2023

Choose a reason for hiding this comment

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

Strangely, the logic in test_fetch::test_offset would exhaust this zip object, causing it to be empty when test_fetch::test_decimal was run, causing the latter test to fail.

It's possible that ORDER BY on the upstream table causes DecimalPrimaryKey to also sort (and therefore exhaust the zip object):

https://github.com/ethho/datajoint-python/blob/761c1663f4a2be45e521e84f3d33ef79b34b3ba4/tests/test_fetch.py#L205-L207

    def test_offset(self, schema_any, lang, languages):
        """Tests offset"""
        cur = lang.fetch(limit=4, offset=1, order_by=["language", "name DESC"])

Whatever the cause, changing the contents from a zip to a list prevents these tests from interfering with each other.

Copy link
Member

Choose a reason for hiding this comment

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

zip can only be used once. Once exhausted, it's empty. So if you are using the same code more than once to populate a lookup table, you need to convert into a list first.



class IndexRich(dj.Manual):
Expand Down
Loading