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

PLAT-156: Migrate test_fetch #1129

Merged
merged 10 commits into from
Dec 13, 2023
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