← Winnitude! Search  ·  Reader Mode (1427 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 41 LINKS

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:

  1. the tests that hard crash are temporarily disabled via pytest.mark.xfail, for convenience;
  2. 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.
  3. I haven't checked that this works with older versions of Python, it's a quick draft
DiegoBaldassarMilleuno mentioned this pull request Dec 20, 2024 Unimplemented or broken methods in Python wrappers to standard C# containers #2531 Open lostmsu reviewed Apr 21, 2026
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
Comment thread tests/test_collection_mixins_mapping.py Comment on lines +95 to +98
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
Comment thread tests/test_collection_mixins_mapping.py
with pytest.raises(Exception):
dct[12.34] = self.vtype(0)

@pytest.mark.xfail(reason='Known to crash', run=False)
filmor force-pushed the fix-collection-mixins branch 2 times, most recently from 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 indexes
filmor 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

Labels

None yet

2 participants