Skip to content

Running pytest against non develop install fails #6973

Closed

Description

@jenshnielsen

Running the tests against master. To reproduce do

pip install .
py.test -ra

First problem is that matplotlib.testing.nose isn't installed. That is easy to fix by adding it to setupext.py

But I am not sure what to do about the next problem:

=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.5.2, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
rootdir: /Users/jhn/src/python/matplotlib, inifile: pytest.ini
plugins: cov-2.3.1, faulthandler-1.3.0, timeout-1.0.0, xdist-1.15.0
collected 0 items / 67 errors

...

____________________________________________________________________ ERROR collecting lib/matplotlib/sphinxext/tests/test_tinypages.py _____________________________________________________________________
import file mismatch:
imported module 'matplotlib.sphinxext.tests.test_tinypages' has this __file__ attribute:
  /Users/jhn/Envs/mplmaster/lib/python3.5/site-packages/matplotlib/sphinxext/tests/test_tinypages.py
which is not the same as the test file we want to collect:
  /Users/jhn/src/python/matplotlib/lib/matplotlib/sphinxext/tests/test_tinypages.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules

Activity

  1. Kojoley commented on Aug 24, 2016

    @Kojoley
    Member

    I think that the second problem can only be fixed by replacing all absolute imports with relative ones or vice versa.
    Relative imports will allow to run tests without installing matplotlib.

  2. added this to the milestone on Aug 24, 2016
  3. QuLogic commented on Aug 25, 2016

    @QuLogic
    Member

    That seems a bit drastic. The "good practices" seem to indicate that tests should not include __init__.py. Or for inline and importable tests, running the tests directly on the installed package with py.test -ra --pyargs matplotlib should work.

  4. phobson commented on Mar 16, 2017

    @phobson
    Member

    Has this issue gone stale?

  5. QuLogic commented on Mar 16, 2017

    @QuLogic
    Member

    I don't really think it's a bug, TBH; pytest just does things slightly different.

  6. anntzer commented on Mar 23, 2017

    @anntzer
    Contributor

    FWIW #8135 solves this problem by making the installation step unnecessary.

  7. modified the milestones: , on Oct 3, 2017
  8. QuLogic commented on Feb 10, 2018

    @QuLogic
    Member

    I'm closing this as I don't think it's a bug, and we have other issues for whether we want to add setup.py test.

  9. removed this from the milestone on Feb 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions