3

I specify installing pytest in Drone pipeline as below:

pip install -q pytest

it used to work well until a few days ago when it suddenly showed below error:

+ python -m pytest test/test_dai_adrecogzer.py
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pytest.py", line 14, in <module>
    from _pytest.fixtures import fillfixtures as _fillfuncargs
  File "/usr/local/lib/python2.7/dist-packages/_pytest/fixtures.py", line 16, in <module>
    from more_itertools import flatten
  File "/usr/local/lib/python2.7/dist-packages/more_itertools/__init__.py", line 1, in <module>
    from more_itertools.more import *  # noqa
  File "/usr/local/lib/python2.7/dist-packages/more_itertools/more.py", line 329
    def _collate(*iterables, key=lambda a: a, reverse=False):
                               ^

SyntaxError: invalid syntax

Searching around I found a recently post SO question that seems to closely link to what I am looking for. The reason seems to be because of recently released version 6.0 of more-itertools. The accepted answer suggests to spin to some specific version of more-itertools:

setuptools.setup(
    setup_requires=['pytest-runner'],
    tests_require=['mock', 'more-itertools<6.0.0', 'pytest'],
    test_suite='tests',
    python_requires='>=2.7',
)

How could I apply this suggestion to my issue? More specifically, how could I specify version <6.0.0 of more-itertools when install pytest using pip install -q pytest command?

duong_dajgja
  • 4,196
  • 1
  • 38
  • 65

2 Answers2

1

you could specify a version of pytest that has an old version of more-itertools (for ex: pip install pytest==3.5.0)

I will not advise to install pytest with another version of more-iterators, other then one specified in setuptools because it may cause other crushes(pytest it may depend at some point on some features that your downgraded version doesn't have).

kederrac
  • 16,819
  • 6
  • 32
  • 55
1

According to the pytest package specs on PyPI, the package requires more-itertools >=4.0.0. I would assume that, if you explicitly install any suitable version of more-itertools below 6.0.0 and above or equal 4.0.0, prior to running pip install -q pytest, the dependency check for more-itertools would already be satisfied and you could install the most recent version of pytest.

shmee
  • 4,721
  • 2
  • 18
  • 27