gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

Test failure with Python 3.12 #249

Closed thesamesam closed 7 months ago

thesamesam commented 1 year ago

I get the following test failure with Python 3.12 beta1 with pyquery-2.0.0:

_______________________________________________________________________________ [doctest] pyquery.pyquery.PyQuery.serialize_dict _______________________________________________________________________________
1603 Serialize form elements as an ordered dictionary. Multiple values
1604         corresponding to the same input name are concatenated into one list.
1605
1606             >>> d = PyQuery('''<form>
1607             ...             <input name="order" value="spam">
1608             ...             <input name="order" value="eggs">
1609             ...             <input name="order2" value="ham">
1610             ...             </form>''')
1611             >>> d.serialize_dict()
Expected:
    OrderedDict([('order', ['spam', 'eggs']), ('order2', 'ham')])
Got:
    OrderedDict({'order': ['spam', 'eggs'], 'order2': 'ham'})

/var/tmp/portage/dev-python/pyquery-2.0.0/work/pyquery-2.0.0/pyquery/pyquery.py:1611: DocTestFailure
mgorny commented 1 year ago

Gentle ping.

athoune commented 7 months ago

In modern Python, insertion order is preserved for dictionaries. So, the old syntax, with a list of tuple of key-value is no more used.

Good luck to handle that change with a project tested with python from 3.7 to 3.12.