Skip to content

Align dict union test outcomes with CPython 3.9 - #3230

Merged
DimitrisJim merged 2 commits into
RustPython:mainfrom
frazar:fix-dict-union-tests
Oct 6, 2021
Merged

DimitrisJim merged 2 commits into
RustPython:mainfrom
frazar:fix-dict-union-tests

Conversation

@frazar

@frazar frazar commented Oct 5, 2021

Copy link
Copy Markdown
Contributor

Fixes #3212, or at least I believe. Let me know if anything is wrong.

After this PR, running

pytest snippets/dict_union.py

in the "extra_tests" folder does not give any error.

The expected outcomes of the tests was computed with CPython 3.9.7 as follows:

[frazar@hostname extra_tests]$ python
Python 3.9.7 (default, Aug 31 2021, 13:28:12)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> d={1:2}
>>> d.__ior__('FooBar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is required
>>> d.__ior__(42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>> d.__ior__([36])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence
>>> d.__ior__(set([36]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence
>>> d.__ior__(['aa'])
{1: 2, 'a': 'a'}
>>> d.__ior__(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

@frazar frazar changed the title Align test outcomes with CPython 3.9 Align dict union test outcomes with CPython 3.9 Oct 5, 2021
@DimitrisJim DimitrisJim mentioned this pull request Oct 6, 2021

@DimitrisJim DimitrisJim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great, thanks!

@DimitrisJim
DimitrisJim merged commit 2c09dd8 into RustPython:main Oct 6, 2021
@frazar
frazar deleted the fix-dict-union-tests branch October 6, 2021 19:12
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.

compatibility for dict.__or__, dict.__ior__, dict.__ror__

2 participants