Skip to content

Test fails in relational_operand due to test code, not functionality. #1205

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

Open
larsrollik opened this issue Feb 18, 2025 · 0 comments
Open
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@larsrollik
Copy link

Bug Report

Description

Test fails in relational_operand.

Reproducibility

Run test container from datajoint/datajoint-python/docker-comose.yml with Python version 3.11 or 3.9 presets.

Stack trace from pytest:

_________________ TestDjTop.test_top_restriction_with_keywords _________________

self = <tests.test_relational_operand.TestDjTop object at 0x7563c4b042e0>
schema_simp_pop = Schema `djtest_relational`


    def test_top_restriction_with_keywords(self, schema_simp_pop):
        select = SelectPK() & dj.Top(limit=9, order_by=["select desc"])
        key = KeyPK() & dj.Top(limit=9, order_by="key desc")
        assert select.fetch(as_dict=True) == [
            {"id": 2, "select": 8},
            {"id": 2, "select": 6},
            {"id": 1, "select": 4},
            {"id": 2, "select": 4},
            {"id": 1, "select": 3},
            {"id": 1, "select": 2},
            {"id": 2, "select": 2},
            {"id": 1, "select": 1},
            {"id": 0, "select": 0},
        ]
>       assert key.fetch(as_dict=True) == [
            {"id": 2, "key": 6},
            {"id": 2, "key": 5},
            {"id": 1, "key": 5},
            {"id": 0, "key": 4},
            {"id": 1, "key": 4},
            {"id": 2, "key": 4},
            {"id": 0, "key": 3},
            {"id": 1, "key": 3},
            {"id": 2, "key": 3},
        ]
E       AssertionError: assert [{'id': 2, 'k...key': 4}, ...] == [{'id': 2, 'k...key': 4}, ...]
E         
E         At index 1 diff: {'id': 1, 'key': 5} != {'id': 2, 'key': 5}
E         Use -v to get more diff

tests/test_relational_operand.py:629: AssertionError

Additional Research and Context

Offending lines are these: https://github.com/datajoint/datajoint-python/blob/eef7e59316a05349dc662f34928403808d93e49c/tests/test_relational_operand.py#L631-632

Original:

        assert key.fetch(as_dict=True) == [
            {"id": 2, "key": 6},
            {"id": 2, "key": 5},  # <<
            {"id": 1, "key": 5},  # <<
            {"id": 0, "key": 4},
            {"id": 1, "key": 4},
            {"id": 2, "key": 4},
            {"id": 0, "key": 3},
            {"id": 1, "key": 3},
            {"id": 2, "key": 3},
        ]

Suggested fix: Swap lines for key==5:

        assert key.fetch(as_dict=True) == [
            {"id": 2, "key": 6},
            {"id": 1, "key": 5},
            {"id": 2, "key": 5},
            {"id": 0, "key": 4},
            {"id": 1, "key": 4},
            {"id": 2, "key": 4},
            {"id": 0, "key": 3},
            {"id": 1, "key": 3},
            {"id": 2, "key": 3},
        ]

Additional

Relevant for open PR #1197

@larsrollik larsrollik added the bug Indicates an unexpected problem or unintended behavior label Feb 18, 2025
@dimitri-yatsenko dimitri-yatsenko self-assigned this Feb 21, 2025
@yambottle yambottle added stale Indicates issues, pull requests, or discussions are inactive and removed stale Indicates issues, pull requests, or discussions are inactive labels Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants