question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test suite fails in Docker (Python 3.6.5)

See original GitHub issue

When I run the test suite in a Python Docker container, there are 5 failures (not including the 17 skipped tests):

  • TestPipenv.test_complex_lock
  • TestPipenv.test_backup_resolver
  • TestPipenv.test_complex_deps_lock_and_install_properly
  • TestPipenv.test_complex_lock_deep_extras
  • TestPipenv.test_deploy_works

There seems to be some overlap with what’s mentioned here.

Empirically, these failures appear to be deterministic (I’ve run the tests from clean twice, with the same results).

I’m not sure if this is Docker-specific yet - this is my first attempt to run the test suite, so I’ll do some digging. But without the ability to run the tests in an isolated env, I’m not going to be able to make the changes I want to contribute 😢

EDIT: Updated from 3.6.4 to 3.6.5 as that’s no longer an official tag on Docker Hub.


Expected result

All the tests to pass.

Actual result
Test output
Loading .env environment variables…
================================================ test session starts =================================================
platform linux -- Python 3.6.5, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /pipenv, inifile:
plugins: xdist-1.22.2, tap-2.2, forked-0.2, pypi-0.1.1
collected 113 items

tests/test_pipenv.py ............s.F.......s.....F..........s.ssss.....FFF..........                           [ 55%]
tests/test_utils.py .....................s....sss..ssssss...........                                           [ 98%]
tests/test_vendor.py ..                                                                                        [100%]

====================================================== FAILURES ======================================================
____________________________________________ TestPipenv.test_complex_lock ____________________________________________

self = <tests.test_pipenv.TestPipenv object at 0x7fc0a3b48780>
pypi = <pytest_pypi.serve.Server object at 0x7fc0a3b18ac8>

    @pytest.mark.complex_lock
    def test_complex_lock(self, pypi):
        with PipenvInstance(pypi=pypi) as p:
            c = p.pipenv('install apscheduler')
            assert c.return_code == 0
            assert 'apscheduler' in p.pipfile['packages']
>           assert 'funcsigs' in p.lockfile[u'default']
E           AssertionError: assert 'funcsigs' in {'apscheduler': {'hashes': ['sha256:443d015339ceca347f9ed14a66e9b610f99f19f8ef9048aa1cdabee2560824e1', 'sha256:952c8f4...zlocal': {'hashes': ['sha256:4ebeb848845ac898da6519b9b31879cf13b6626f7184c496037b818e238f2c4e'], 'version': '==1.5.1'}}

tests/test_pipenv.py:280: AssertionError
------------------------------------------------ Captured stdout call ------------------------------------------------
$ pipenv install apscheduler
Installing apscheduler…
Collecting apscheduler
  Downloading http://127.0.0.1:37523/apscheduler/APScheduler-3.5.1-py2.py3-none-any.whl (60kB)
Collecting six>=1.4.0 (from apscheduler)
  Downloading http://127.0.0.1:37523/six/six-1.11.0-py2.py3-none-any.whl
Collecting tzlocal>=1.2 (from apscheduler)
  Downloading http://127.0.0.1:37523/tzlocal/tzlocal-1.5.1.tar.gz
Collecting pytz (from apscheduler)
  Downloading http://127.0.0.1:37523/pytz/pytz-2018.3-py2.py3-none-any.whl (509kB)
Requirement already satisfied: setuptools>=0.7 in ./.venv/lib/python3.6/site-packages (from apscheduler)
Building wheels for collected packages: tzlocal
  Running setup.py bdist_wheel for tzlocal: started
  Running setup.py bdist_wheel for tzlocal: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/e1/21/0c/12bb9a3ca56b4b4799c671d211574c4bfd496fcb06e2481c71
Successfully built tzlocal
Installing collected packages: six, pytz, tzlocal, apscheduler
Successfully installed apscheduler-3.5.1 pytz-2018.3 six-1.11.0 tzlocal-1.5.1

Adding apscheduler to Pipfile's [packages]…
Installing dependencies from Pipfile.lock (aaadfc)…
To activate this project's virtualenv, run the following:
 $ pipenv shell

Creating a virtualenv for this project…
Using /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python (3.6.5) to create virtualenv…
Already using interpreter /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python
Using real prefix '/usr/local'
New python executable in /tmp/pipenv-pynalup0-project/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /tmp/pipenv-pynalup0-project/.venv
Creating a Pipfile for this project…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (aaadfc)!

------------------------------------------------ Captured stderr call ------------------------------------------------
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /simple/apscheduler/ HTTP/1.1" 200 396
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /apscheduler/APScheduler-3.5.1-py2.py3-none-any.whl HTTP/1.1" 200 60578
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /simple/six/ HTTP/1.1" 200 320
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /six/six-1.11.0-py2.py3-none-any.whl HTTP/1.1" 200 10702
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /simple/tzlocal/ HTTP/1.1" 200 243
127.0.0.1 - - [02/Apr/2018 13:33:51] "GET /tzlocal/tzlocal-1.5.1.tar.gz HTTP/1.1" 200 16809
127.0.0.1 - - [02/Apr/2018 13:33:52] "GET /simple/pytz/ HTTP/1.1" 200 330
127.0.0.1 - - [02/Apr/2018 13:33:52] "GET /pytz/pytz-2018.3-py2.py3-none-any.whl HTTP/1.1" 200 509950
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/apscheduler/ HTTP/1.1" 200 396
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/apscheduler/ HTTP/1.1" 200 396
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /apscheduler/APScheduler-3.5.1-py2.py3-none-any.whl HTTP/1.1" 200 60578
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/pytz/ HTTP/1.1" 200 330
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/six/ HTTP/1.1" 200 320
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/tzlocal/ HTTP/1.1" 200 243
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/six/ HTTP/1.1" 200 320
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /six/six-1.11.0-py2.py3-none-any.whl HTTP/1.1" 200 10702
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/tzlocal/ HTTP/1.1" 200 243
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /tzlocal/tzlocal-1.5.1.tar.gz HTTP/1.1" 200 16809
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/pytz/ HTTP/1.1" 200 330
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /pytz/pytz-2018.3-py2.py3-none-any.whl HTTP/1.1" 200 509950
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/tzlocal/ HTTP/1.1" 200 243
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /tzlocal/tzlocal-1.5.1.tar.gz HTTP/1.1" 200 16809
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/apscheduler/ HTTP/1.1" 200 396
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /apscheduler/APScheduler-3.5.1.tar.gz HTTP/1.1" 200 93129
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /apscheduler/APScheduler-3.5.1-py2.py3-none-any.whl HTTP/1.1" 200 60578
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/six/ HTTP/1.1" 200 320
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /six/six-1.11.0-py2.py3-none-any.whl HTTP/1.1" 200 10702
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /six/six-1.11.0.tar.gz HTTP/1.1" 200 29860
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /simple/pytz/ HTTP/1.1" 200 330
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /pytz/pytz-2018.3-py2.py3-none-any.whl HTTP/1.1" 200 509950
127.0.0.1 - - [02/Apr/2018 13:33:54] "GET /pytz/pytz-2018.3.tar.gz HTTP/1.1" 200 314214
__________________________________________ TestPipenv.test_backup_resolver ___________________________________________

self = <tests.test_pipenv.TestPipenv object at 0x7fc0a3c240b8>

    @pytest.mark.install
    @pytest.mark.resolver
    @pytest.mark.backup_resolver
    @needs_internet
    def test_backup_resolver(self):
        with PipenvInstance() as p:
            with open(p.pipfile_path, 'w') as f:
                contents = """
    [packages]
    "ibm-db-sa-py3" = "==0.3.1-1"
                    """.strip()
                f.write(contents)

            c = p.pipenv('install')
>           assert c.return_code == 0
E           AssertionError: assert 1 == 0
E            +  where 1 = <Command 'pipenv install'>.return_code

tests/test_pipenv.py:588: AssertionError
------------------------------------------------ Captured stdout call ------------------------------------------------
$ pipenv install

Creating a virtualenv for this project…
Using /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python (3.6.5) to create virtualenv…
Already using interpreter /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python
Using real prefix '/usr/local'
New python executable in /tmp/pipenv-roc487pg-project/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /tmp/pipenv-roc487pg-project/.venv
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…

CRITICAL:notpip.index:Could not find a version that satisfies the requirement ibm-db-sa-py3==0.3.1-1 (from versions: )
Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
No matching distribution found for ibm-db-sa-py3==0.3.1-1


------------------------------------------------ Captured stderr call ------------------------------------------------
127.0.0.1 - - [02/Apr/2018 13:37:25] "GET /simple/ibm-db-sa-py3/ HTTP/1.1" 404 233
127.0.0.1 - - [02/Apr/2018 13:37:25] "GET /simple/ibm-db-sa-py3/ HTTP/1.1" 404 233
_______________________________ TestPipenv.test_complex_deps_lock_and_install_properly _______________________________

self = <tests.test_pipenv.TestPipenv object at 0x7fc0a3c1f6a0>

    @pytest.mark.lock
    @pytest.mark.requirements
    @pytest.mark.complex
    @pytest.mark.maya
    @needs_internet
    def test_complex_deps_lock_and_install_properly(self):
        # This uses the real PyPI because Maya has too many dependencies...
        with PipenvInstance() as p:
            with open(p.pipfile_path, 'w') as f:
                contents = """
    [packages]
    maya = "*"
                    """.strip()
                f.write(contents)

            c = p.pipenv('lock')
>           assert c.return_code == 0
E           AssertionError: assert 1 == 0
E            +  where 1 = <Command 'pipenv lock'>.return_code

tests/test_pipenv.py:1023: AssertionError
------------------------------------------------ Captured stdout call ------------------------------------------------
$ pipenv lock

Creating a virtualenv for this project…
Using /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python (3.6.5) to create virtualenv…
Already using interpreter /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python
Using real prefix '/usr/local'
New python executable in /tmp/pipenv-6j71aipp-project/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /tmp/pipenv-6j71aipp-project/.venv
Locking [dev-packages] dependencies…
Locking [packages] dependencies…

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Could not find a version that matches maya
Tried: (no version found at all)


------------------------------------------------ Captured stderr call ------------------------------------------------
127.0.0.1 - - [02/Apr/2018 13:39:22] "GET /simple/maya/ HTTP/1.1" 404 233
127.0.0.1 - - [02/Apr/2018 13:39:22] "GET /simple/maya/ HTTP/1.1" 404 233
______________________________________ TestPipenv.test_complex_lock_deep_extras ______________________________________

self = <tests.test_pipenv.TestPipenv object at 0x7fc0a2a02390>

    @pytest.mark.extras
    @pytest.mark.lock
    @pytest.mark.complex
    @needs_internet
    def test_complex_lock_deep_extras(self):
        # records[pandas] requires tablib[pandas] which requires pandas.
        # This uses the real PyPI; Pandas has too many requirements to mock.

        with PipenvInstance() as p:
            with open(p.pipfile_path, 'w') as f:
                contents = """
    [packages]
    records = {extras = ["pandas"], version = "==0.5.2"}
                    """.strip()
                f.write(contents)

            c = p.pipenv('install')
>           assert c.return_code == 0
E           AssertionError: assert 1 == 0
E            +  where 1 = <Command 'pipenv install'>.return_code

tests/test_pipenv.py:1045: AssertionError
------------------------------------------------ Captured stdout call ------------------------------------------------
$ pipenv install

Creating a virtualenv for this project…
Using /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python (3.6.5) to create virtualenv…
Already using interpreter /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python
Using real prefix '/usr/local'
New python executable in /tmp/pipenv-p6sndah3-project/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /tmp/pipenv-p6sndah3-project/.venv
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Could not find a version that matches pandas
Tried: (no version found at all)


------------------------------------------------ Captured stderr call ------------------------------------------------
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/records/ HTTP/1.1" 200 356
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /records/records-0.5.2-py2.py3-none-any.whl HTTP/1.1" 200 12022
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/docopt/ HTTP/1.1" 200 237
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/sqlalchemy/ HTTP/1.1" 200 362
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/tablib/ HTTP/1.1" 200 405
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/tablib/ HTTP/1.1" 200 405
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /tablib/tablib-0.12.1.tar.gz HTTP/1.1" 200 63420
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /simple/docopt/ HTTP/1.1" 200 237
127.0.0.1 - - [02/Apr/2018 13:39:26] "GET /docopt/docopt-0.6.2.tar.gz HTTP/1.1" 200 25901
127.0.0.1 - - [02/Apr/2018 13:39:27] "GET /simple/sqlalchemy/ HTTP/1.1" 200 362
127.0.0.1 - - [02/Apr/2018 13:39:27] "GET /sqlalchemy/SQLAlchemy-1.2.4.tar.gz HTTP/1.1" 200 5555033
127.0.0.1 - - [02/Apr/2018 13:39:27] "GET /simple/records/ HTTP/1.1" 200 356
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/odfpy/ HTTP/1.1" 200 314
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/openpyxl/ HTTP/1.1" 200 249
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/pandas/ HTTP/1.1" 404 233
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/records/ HTTP/1.1" 200 356
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/docopt/ HTTP/1.1" 200 237
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/sqlalchemy/ HTTP/1.1" 200 362
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/tablib/ HTTP/1.1" 200 405
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/tablib/ HTTP/1.1" 200 405
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/records/ HTTP/1.1" 200 356
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/odfpy/ HTTP/1.1" 200 314
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/openpyxl/ HTTP/1.1" 200 249
127.0.0.1 - - [02/Apr/2018 13:39:28] "GET /simple/pandas/ HTTP/1.1" 404 233
____________________________________________ TestPipenv.test_deploy_works ____________________________________________

self = <tests.test_pipenv.TestPipenv object at 0x7fc0a2a2eba8>
pypi = <pytest_pypi.serve.Server object at 0x7fc0a3b18ac8>

    @pytest.mark.lock
    @pytest.mark.deploy
    def test_deploy_works(self, pypi):

        with PipenvInstance(pypi=pypi) as p:
            with open(p.pipfile_path, 'w') as f:
                contents = """
    [packages]
    requests = "==2.14.0"
    flask = "==0.12.2"
    [dev-packages]
    pytest = "==3.1.1"
                    """.strip()
                f.write(contents)
            c = p.pipenv('install')
>           assert c.return_code == 0
E           AssertionError: assert 1 == 0
E            +  where 1 = <Command 'pipenv install'>.return_code

tests/test_pipenv.py:1066: AssertionError
------------------------------------------------ Captured stdout call ------------------------------------------------
$ pipenv install

Creating a virtualenv for this project…
Using /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python (3.6.5) to create virtualenv…
Already using interpreter /root/.local/share/virtualenvs/pipenv-4aiTdSJZ/bin/python
Using real prefix '/usr/local'
New python executable in /tmp/pipenv-kxwbcnat-project/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /tmp/pipenv-kxwbcnat-project/.venv
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…

CRITICAL:notpip.index:Could not find a version that satisfies the requirement pytest==3.1.1 (from versions: )
Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
No matching distribution found for pytest==3.1.1


------------------------------------------------ Captured stderr call ------------------------------------------------
127.0.0.1 - - [02/Apr/2018 13:39:31] "GET /simple/pytest/ HTTP/1.1" 404 233
127.0.0.1 - - [02/Apr/2018 13:39:31] "GET /simple/pytest/ HTTP/1.1" 404 233
================================= 5 failed, 91 passed, 17 skipped in 508.25 seconds ==================================
Steps to replicate

Spin up a Python container:

docker run --rm -it python:3.6.5 /bin/bash
docker inspect --format='{{index .RepoDigests 0}}' python:3.6.5    # python@sha256:5feadaa5837182a9b8e04a596ea8510f6e88a1455d286dbdd0b185fced9a21f7

Then clone the code, install stuff, and run the test suite per the instructions in CONTRIBUTING.rst:

git clone https://github.com/pypa/pipenv.git
cd pipenv
git rev-parse HEAD        # 8a67a21d61a2383253fe0dd5e7a8d79d51d30d2d
python setup.py develop
pipenv install --dev
pipenv run pytest tests

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
tsiq-olivercommented, Apr 8, 2018

This seems to be fixed now given the recent test updates.

0reactions
techalchemycommented, Apr 4, 2018

@txomon I think you were probably being sarcastic but unfortunately yes, downloading packages, executing their various setup files, compiling them (if necessary), hashing them, doing a hash comparison, and then resolving the full dependency graph sometimes takes a few minutes even. I realize this may seem horrible or something, but if you don’t need dependency resolution safety in your environment feel free to use --skip-lock. If you have an idea for speeding this up feel free to submit a pr.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install Python 3.6.5 but got Python 3.6.6 in Docker
Your apt-get command silently install Python 3.6.6 because one of those programs has dependency on python, see the log:
Read more >
Run Python Versions in Docker: How to Try the Latest Python ...
Start a Python REPL through Docker; Set up your Python environment inside a Docker image; Run scripts inside Docker containers. As you test...
Read more >
Vulnerability report for Docker python:3.6-slim-buster - Snyk
Docker image python has 117 known vulnerabilities found in 188 vulnerable paths. ... Test your Docker Hub image against our market leading vulnerability ......
Read more >
test_os.py fails when run in docker container on OSX host
msg311921 ‑ (view) Author: Alexander Mohr (thehesiod) * Date: 2018‑02‑10 00:29 msg311924 ‑ (view) Author: Alexander Mohr (thehesiod) * Date: 2018‑02‑10 00:45 msg311930 ‑ (view)...
Read more >
Run your image as a container - Docker Documentation
Work through the steps to build a Python image in Build your ... As you can see, our curl command failed because the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found