Skip to content

discover should ignore build/ and dist/ by default #1544

Closed
@mikofski

Description

@mikofski

If running py.test from same folder as setup.py then test discovery may enter build/ causing errors. Removing the build/ directory, using --ignore=build and setting norecursedirs for [pytest] in any .ini file all solve the issue, but can py.test be configured to always ignore this folder? Note nose2 and nosetests do not have this issue.

In the case where dynamic module import occurs and the path is specified relative to the test directory, then py.test returns the following stacktrace:

___________ ERROR collecting build/lib/circus/tests/test_outputs.py ___________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
build\lib\my_package\tests\test_this.py:8: in <module>
    fid, fn, info = imp.find_module(MODULE, [PACKAGE])
E   ImportError: No module named dynamic_module

minimalist example

my_package -> tests -> test_this.py

import os
import imp

MODULE = 'dynamic_module'
PACKAGE = os.path.join('path', 'to', 'package', 'of', 'dynamic_module']

# use imp to find and load dynamic module
fid, fn, info = imp.find_module(MODULE, [PACKAGE])
my_module = imp.load_module(MODULE, fid, fn, info)
fid.close()

OS and Python

  • Windows-7 (AMD64)
  • Python-2.7.10 (AMD64) from python.org

py.test --version

This is pytest version 2.9.1, imported from c:\python27\lib\site-packages\pytest.pyc

requirements.txt

pint>=0.7.2
numpy>=1.8.2
xlrd>=0.9.4
nose
sphinx
scipy
python-dateutil
numexpr
pvlib==0.2.2

Thanks for submitting an issue!

Here's a quick checklist in what to include:

  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • py.test and operating system versions
  • Minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorstatus: help wanteddevelopers would like help from experts on this topictype: enhancementnew feature or API change, should be merged into features branchtype: feature-branchnew feature or API change, should be merged into features branchtype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions