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

Implement __index__ to avoid TypeError #47

Merged
merged 2 commits into from
Jan 25, 2024
Merged

Implement __index__ to avoid TypeError #47

merged 2 commits into from
Jan 25, 2024

Conversation

larsevj
Copy link
Collaborator

@larsevj larsevj commented Jan 19, 2024

Issue
Resolves #46

Approach
This makes the tests in resdata pass, but maybe we should add some tests in cwrap?

@larsevj larsevj requested a review from andreas-el January 24, 2024 08:57
@andreas-el
Copy link

Issue Resolves #46

Approach This makes the tests in resdata pass, but maybe we should add some tests in cwrap?

Yep, we could for example add something like this to test the __index__():

    def test_dunder_index(self):
        class index_enum(BaseCEnum):
            pass

        index_enum.addEnum("ONE", 1)
        index_enum.addEnum("TWO", 2)
        index_enum.addEnum("THREE", 3)

        value_list = [10, 20, 30, 40]
        value = value_list[index_enum.TWO]
        assert(value == 30)

Copy link

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

I agree, let's add a test to this fixup.

@larsevj larsevj force-pushed the build_komodo_levje branch from 8f94d76 to d88daea Compare January 24, 2024 16:51
Copy link

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

Great, and some nice cleanup too! 🚀

Test for implicit conversion to c_int which is deprecated in Python3.11.
Use Pytest to run tests, and remove unused/old tests.
@larsevj larsevj force-pushed the build_komodo_levje branch from d88daea to 09ff7cf Compare January 25, 2024 11:38
@larsevj larsevj merged commit 3bf6c8e into main Jan 25, 2024
32 checks passed
@larsevj larsevj deleted the build_komodo_levje branch January 25, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instances of baseCenum is not treated as int by ctypes in python3.11
2 participants