Add tests for collection mixins (see issue #2531) by DiegoBaldassarMilleuno · Pull Request #2535 · pythonnet/pythonnet
Repository navigation
Add tests for collection mixins (see issue #2531) - #2535
Draft
DiegoBaldassarMilleuno wants to merge 2 commits into pythonnet:master from DiegoBaldassarMilleuno:fix-collection-mixins
Draft
Add tests for collection mixins (see issue #2531) #2535 DiegoBaldassarMilleuno wants to merge 2 commits into pythonnet:master from DiegoBaldassarMilleuno:fix-collection-mixins
Conversation
DiegoBaldassarMilleuno commented Dec 20, 2024
Copy link Copy Markdown
As requested in #2531 (comment) , submitting a draft pull request testing for compliance to collections.abc protocols by a few standard containers.
Currently many tests fail.
A few notes:
- the tests that hard crash are temporarily disabled via
pytest.mark.xfail, for convenience; - many requirements I added in these tests are rather pedantic (like supporting values of the wrong type in
__contains__or requiring specific exceptions to be thrown); maintainers feel free to remove any that you believe are outside of contract. - I haven't checked that this works with older versions of Python, it's a quick draft
View reviewed changes
Comment thread tests/test_collection_mixins_mapping.py
|
|
||
| def test_len(self): | ||
| assert type(len(self.dct)) is int | ||
| assert len(self.dct) == 4 if not self.nullable else 5 |
| def test_contains(self): | ||
| assert self.ktype(10) in self.dct | ||
| assert self.ktype(50) not in self.dct | ||
| assert 12.34 not in self.dct |
| with pytest.raises(Exception): | ||
| dct[12.34] = self.vtype(0) | ||
|
|
||
| @pytest.mark.xfail(reason='Known to crash', run=False) |
aa46aa0 to
fbf5026
Compare
May 12, 2026 20:28 DiegoBaldassarMilleuno added 2 commits September 29, 2026 14:00
Add tests for collection mixins (see issue pythonnet#2531)
66bc871
Adding testing for adherence to collections.abc protocols for the following classes: Array, List, ImmutableArray, ImmutableList, Dictionary, ImmutableDictionary and ReadOnlyDictionary Tests for Python list and dict are also present as a reference but commented out.
Added missing type conversions in mixin tests
f8ba73d
Also made sequence __deitem__ test not rely on negative indexesfilmor force-pushed the fix-collection-mixins branch from
fbf5026 to
f8ba73d
Compare
September 29, 2026 12:00
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment