[TIP] pytest installation - setuptools causing failures

Dale Potter dalepotter at gmail.com
Wed Jul 13 01:52:18 PDT 2016


Hello,

I am having some interesting errors when trying to set up pytest on a mac
with a project that uses virtualenv.

I’ve run the installation instructions on
http://docs.pytest.org/en/latest/getting-started.html :


1) pip install -U pytest

2) Created a file ‘test_sample.py’ with contents:

def func(x):
    return x + 1

def test_answer():
    assert func(3) == 5

3) Running py.test gives the output below.


Any help in getting to the bottom of this is much appreciated. At the
moment, my workaround is to use create a vagrant virtualbox to run the
tests, but this means manually setting up and replicating test files
whenever code changes are made.

Could this be an issue with running python version 3.4 in a virtualenv,
whereas the system default is python version 2.7? Or an issue with
virtualenv set up somewhere??  I have tried uninstalling pytest and
reinstalling (using pip commands), but have experienced the same results.

Many thanks,
Dale



============================= test session starts
==============================
platform darwin -- Python 2.7.6, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /Users/username/Documents/Project-Public-Validator, inifile:
plugins: cov-2.2.1
collected 82 items / 3 errors / 1 skipped

test_sample.py F
pyenv/lib/python3.4/site-packages/setuptools/tests/test_bdist_egg.py E
pyenv/lib/python3.4/site-packages/setuptools/tests/test_build_ext.py .
pyenv/lib/python3.4/site-packages/setuptools/tests/test_develop.py .
pyenv/lib/python3.4/site-packages/setuptools/tests/test_dist_info.py ..
pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py
......EEEEE...........
pyenv/lib/python3.4/site-packages/setuptools/tests/test_egg_info.py E
pyenv/lib/python3.4/site-packages/setuptools/tests/test_find_packages.py
...........
pyenv/lib/python3.4/site-packages/setuptools/tests/test_integration.py .x.x
pyenv/lib/python3.4/site-packages/setuptools/tests/test_markerlib.py .
pyenv/lib/python3.4/site-packages/setuptools/tests/test_packageindex.py
......F........
pyenv/lib/python3.4/site-packages/setuptools/tests/test_sandbox.py .s.......
pyenv/lib/python3.4/site-packages/setuptools/tests/test_sdist.py .......
pyenv/lib/python3.4/site-packages/setuptools/tests/test_test.py s
pyenv/lib/python3.4/site-packages/setuptools/tests/test_upload_docs.py E
pyenv/lib/python3.4/site-packages/setuptools/tests/test_windows_wrappers.py
sss
tests/tests.txt s

==================================== ERRORS
====================================
 ERROR collecting
pyenv/lib/python3.4/site-packages/pkg_resources/tests/test_pkg_resources.py
import file mismatch:
imported module 'pkg_resources.tests.test_pkg_resources' has this __file__
attribute:

/Users/username/Documents/Project-Stats/pyenv/lib/python2.7/site-packages/pkg_resources/tests/test_pkg_resources.py
which is not the same as the test file we want to collect:

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/pkg_resources/tests/test_pkg_resources.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your
test file modules
 ERROR collecting
pyenv/lib/python3.4/site-packages/pkg_resources/tests/test_resources.py
import file mismatch:
imported module 'pkg_resources.tests.test_resources' has this __file__
attribute:

/Users/username/Documents/Project-Stats/pyenv/lib/python2.7/site-packages/pkg_resources/tests/test_resources.py
which is not the same as the test file we want to collect:

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/pkg_resources/tests/test_resources.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your
test file modules
__________________ ERROR collecting tests/test_wellformed.py
___________________
tests/test_wellformed.py:1: in <module>
    from validate import Validate_Project_XML
validate.py:2: in <module>
    from lxml import etree
E   ImportError:
dlopen(/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/lxml/etree.so,
2): Symbol not found: _PyBytes_Type
E     Referenced from:
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/lxml/etree.so
E     Expected in: flat namespace
E    in
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/lxml/etree.so
____________________ ERROR at setup of Test.test_bdist_egg
_____________________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_bdist_egg.py,
line 29
      def test_bdist_egg(self, setup_context, user_override):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, monkeypatch, record_xml_property, capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_bdist_egg.py:29
_______ ERROR at setup of TestUserInstallTest.test_user_install_implied
________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py,
line 157
      @mock.patch('setuptools.command.easy_install.__file__', None)
      def test_user_install_implied(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, distutils_package, monkeypatch, record_xml_property,
capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py:157
_________ ERROR at setup of TestUserInstallTest.test_multiproc_atexit
__________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py,
line 169
      def test_multiproc_atexit(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, distutils_package, monkeypatch, record_xml_property,
capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py:169
 ERROR at setup of
TestUserInstallTest.test_user_install_not_implied_without_usersite_enabled
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py,
line 180
      def test_user_install_not_implied_without_usersite_enabled(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, distutils_package, monkeypatch, record_xml_property,
capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py:180
____________ ERROR at setup of TestUserInstallTest.test_local_index
____________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py,
line 190
      def test_local_index(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, distutils_package, monkeypatch, record_xml_property,
capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py:190
__________ ERROR at setup of TestUserInstallTest.test_setup_requires
___________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py,
line 248
      def test_setup_requires(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, setup_context,
cov, cache, recwarn, distutils_package, monkeypatch, record_xml_property,
capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_easy_install.py:248
________ ERROR at setup of TestEggInfo.test_egg_base_installed_egg_info
________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_egg_info.py,
line 56
      def test_egg_base_installed_egg_info(self, tmpdir_cwd, env):
        fixture 'tmpdir_cwd' not found
        available fixtures: tmpdir_factory, pytestconfig, cov, cache,
recwarn, monkeypatch, env, record_xml_property, capfd, capsys, tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_egg_info.py:56
___________ ERROR at setup of TestUploadDocsTest.test_create_zipfile
___________
file
/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_upload_docs.py,
line 42
      def test_create_zipfile(self):
        fixture 'user_override' not found
        available fixtures: tmpdir_factory, pytestconfig, cov, cache,
recwarn, sample_project, monkeypatch, record_xml_property, capfd, capsys,
tmpdir
        use 'py.test --fixtures [testpath]' for help on them.

/Users/username/Documents/Project-Public-Validator/pyenv/lib/python3.4/site-packages/setuptools/tests/test_upload_docs.py:42
=================================== FAILURES
===================================
_________________________________ test_answer
__________________________________

    def test_answer():
>       assert func(3) == 5
E       assert 4 == 5
E        +  where 4 = func(3)

test_sample.py:6: AssertionError
_____________________ TestPackageIndex.test_links_priority
_____________________

self = <setuptools.tests.test_packageindex.TestPackageIndex instance at
0x1117c1ef0>

    def test_links_priority(self):
        """
            Download links from the pypi simple index should be used before
            external download links.
            https://bitbucket.org/tarek/distribute/issue/163

            Usecase :
            - someone uploads a package on pypi, a md5 is generated
            - someone manually copies this link (with the md5 in the url)
onto an
              external page accessible from the package page.
            - someone reuploads the package (with a different md5)
            - while easy_installing, an MD5 error occurs because the
external link
              is used
            -> Setuptools should use the link from pypi, not the external
one.
            """
        if sys.platform.startswith('java'):
            # Skip this test on jython because binding to :0 fails
            return

        # start an index server
        server = IndexServer()
        server.start()
        index_url = server.base_url() + 'test_links_priority/simple/'

        # scan a test index
        pi = setuptools.package_index.PackageIndex(index_url)
        requirement = pkg_resources.Requirement.parse('foobar')
        pi.find_packages(requirement)
        server.stop()

        # the distribution has been found
>       assert 'foobar' in pi
E       assert 'foobar' in <setuptools.package_index.PackageIndex object at
0x1119a5e50>

pyenv/lib/python3.4/site-packages/setuptools/tests/test_packageindex.py:125:
AssertionError
----------------------------- Captured stdout call
-----------------------------
Reading
http://127.0.0.1:57719/setuptools/tests/indexes/test_links_priority/simple/foobar/
Scanning index of all packages (this may take a while)
Reading
http://127.0.0.1:57719/setuptools/tests/indexes/test_links_priority/simple/
----------------------------- Captured stderr call
-----------------------------
127.0.0.1 - - [13/Jul/2016 09:26:31] code 404, message File not found
127.0.0.1 - - [13/Jul/2016 09:26:31] "GET
/setuptools/tests/indexes/test_links_priority/simple/foobar/ HTTP/1.1" 404 -
Couldn't find index page for 'foobar' (maybe misspelled?)
127.0.0.1 - - [13/Jul/2016 09:26:31] code 404, message File not found
127.0.0.1 - - [13/Jul/2016 09:26:31] "GET
/setuptools/tests/indexes/test_links_priority/simple/ HTTP/1.1" 404 -
===== 2 failed, 64 passed, 7 skipped, 2 xfailed, 11 error in 31.10 seconds
=====
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20160713/52ebf5a1/attachment-0001.html>


More information about the testing-in-python mailing list