Closed Anakin100100 closed 2 years ago
Hi, thanks for sharing; i'm looking into this now :)
Hi, I'm afraid I can't repo this issue - I installed the versions of Python and pytest from your test dump on a clean VM, cloned and built the repo and the tests passed:
(endplay) dominic@debian:~/src/endplay$ pytest
============================ test session starts ============================
platform linux -- Python 3.8.10, pytest-4.4.0, py-1.11.0, pluggy-1.0.0
rootdir: /home/dominic/src/endplay
collected 48 items
tests/test_dds.py .... [ 8%]
tests/test_dealer.py ........ [ 25%]
tests/test_evaluate.py ......... [ 43%]
tests/test_interact.py .. [ 47%]
tests/test_parser.py ...... [ 60%]
tests/test_types.py ................... [100%]
========================= 48 passed in 9.68 seconds =========================
Could you post the output of pip list
on your system so I can check if it is incompatibility with versions of one of the packages on your system? I've just pushed a new commit to fix a separate issue so it might also be worth pulling the latest version of the repo and trying again to see if it has serendipitously fixed the issue.
I'm able to replicate the error on the newest repo version and on a clean virtual environnement. It should be noted that I'm using Ubuntu 20.04 on WSL.
(error_test) pawel@LAPTOP-UEFA1UGU:~/endplay$ pip list Package Version
cmake 3.22.3 pip 20.0.2 pkg-resources 0.0.0 setuptools 44.0.0 wheel 0.37.1 (error_test) pawel@LAPTOP-UEFA1UGU:~/endplay$ pytest . =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.10, pytest-4.4.0, py-1.11.0, pluggy-1.0.0 rootdir: /home/pawel/endplay collected 48 items
tests/test_dds.py .... [ 8%] tests/test_dealer.py ........ [ 25%] tests/test_evaluate.py ......... [ 43%] tests/test_interact.py .. [ 47%] tests/test_parser.py .F...F [ 60%] tests/test_types.py ................... [100%]
================================================================================= FAILURES ================================================================================= _ TestPBN.test_02 __
self =
def test_02(self):
file = basedir / "pbn" / "example2.pbn"
self.assertLoadsDumpsEqual(file)
tests/test_parser.py:37:
tests/test_parser.py:26: in assertLoadsDumpsEqual sout = pbn.dumps(boards) ../.local/lib/python3.8/site-packages/endplay/parsers/pbn.py:506: in dumps parser.export_file(boards, sp) ../.local/lib/python3.8/site-packages/endplay/parsers/pbn.py:481: in export_file self.export_board(board) ../.local/lib/python3.8/site-packages/endplay/parsers/pbn.py:449: in export_board table = tabularise_play( ../.local/lib/python3.8/site-packages/endplay/utils/play.py:98: in tabularise_play for trick in grouper(play, 4, pad_value):
n = [Card('D4'), Card('DJ'), Card('D3'), Card('D5'), Card('S2'), Card('S3'), ...], iterable = 4, fillvalue = Card('NT2')
def grouper(n, iterable, fillvalue=None):
"""Collect data into fixed-length chunks or blocks.
>>> list(grouper(3, 'ABCDEFG', 'x'))
[('A', 'B', 'C'), ('D', 'E', 'F'), ('G', 'x', 'x')]
"""
args = [iter(iterable)] * n
E TypeError: 'int' object is not iterable
/usr/lib/python3/dist-packages/moreitertools/recipes.py:295: TypeError ____ TestLIN.test_01 __
self =
def test_01(self):
file = basedir / "lin" / "example1.lin"
self.assertLoadsDumpsEqual(file)
tests/test_parser.py:85:
tests/test_parser.py:79: in assertLoadsDumpsEqual boards = lin.loads(sin) ../.local/lib/python3.8/site-packages/endplay/parsers/lin.py:148: in loads return parser.parse_string(s) ../.local/lib/python3.8/site-packages/endplay/parsers/lin.py:88: in parse_string boards.append(self.parse_line(line)) ../.local/lib/python3.8/site-packages/endplay/parsers/lin.py:76: in parse_line tricks = total_tricks(play, contract.denom) ../.local/lib/python3.8/site-packages/endplay/utils/play.py:33: in total_tricks for trick in grouper(play, 4):
n = [Card('C9'), Card('C3'), Card('C2'), Card('CK'), Card('HA'), Card('H3'), ...], iterable = 4, fillvalue = None
def grouper(n, iterable, fillvalue=None):
"""Collect data into fixed-length chunks or blocks.
>>> list(grouper(3, 'ABCDEFG', 'x'))
[('A', 'B', 'C'), ('D', 'E', 'F'), ('G', 'x', 'x')]
"""
args = [iter(iterable)] * n
E TypeError: 'int' object is not iterable
/usr/lib/python3/dist-packages/more_itertools/recipes.py:295: TypeError =================================================================== 2 failed, 46 passed in 21.62 seconds ===================================================================
Ok, I managed to get the same WSL platform as you and have found the issue; it seems the version of more_itertools
on the wsl platform has switched the order of arguments to grouper
switched:
def grouper(iterable, n, fillvalue=None):
and
def grouper(n, iterable, fillvalue=None):
I'll just copy the definition of the function into the utils file and it should all work...
Fixed in d0c6d04c0a5dac79c4690f0472453844d2a28c45, once the CI tests have run I'll bump a new version to PyPI and close the issue.
Do you know why they would make such a platform specific and bug enducing change?
Seems it was changed in version 6.0.0:
The order of the parameters in grouper() have changed to match the latest recipe in the itertools documentation. Use of the old order will be supported in this release, but emit a DeprecationWarning. The legacy behavior will be dropped in a future release. (thanks to jaraco)
As that release is over three years old, I really don't know why the WSL ubuntu picks up such an old version of the package; especially as the test runners on github also use Ubuntu 20.04 and work fine 🤷♂️...
After cloning the repo and installing the required packages two tests fail.
I encountered the same issue while trying to use the pbn parser .dumps() method.