pytest-dev / pytest-dev/pytest

--pyargs discovery for zipped packages/unpacked wheels/eggs

Open
#1,445 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection type: enhancement
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

EDIT:

Using py.test --pyargs mypackage does not seem to work for .egg distributed packages.
Adding

[easy_install]
zip_ok = False

to setup.cfg seems to be a viable fix until py.test supports zipped packages.

Original issue text:

Using py.test --pyargs mypackage under a conda environment seems to be broken.
I've reported it here: https://github.com/conda/conda/issues/2075

I am reposting it here in case someone has an idea what might be going on here.
Here is a Dockerfile to reproduce the bug:

FROM continuumio/miniconda:3.19.0
MAINTAINER Björn Dahlgren <bjodah@DELETEMEgmail.com>
ENV PATH /opt/miniconda2/bin:$PATH
RUN git clone https://github.com/bjodah/dummypkg.git && \
    cd dummypkg && \
    conda install conda-build pytest && \
    conda build conda-recipe && \
    conda install --use-local dummypkg
RUN cd /tmp && \
    python -c 'import dummypkg; print(dummypkg.__file__)' && \
    python -m pytest --pyargs dummypkg

Running docker build generates the following output:

$ docker build revised-docker-environment/
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon 
Step 0 : FROM continuumio/miniconda:3.19.0
 ---> bc9d0fb804ac
Step 1 : MAINTAINER Björn Dahlgren <bjodah@DELETEMEgmail.com>
 ---> Using cache
 ---> f81cd6785b68
Step 2 : ENV PATH /opt/miniconda2/bin:$PATH
 ---> Using cache
 ---> 3227b31b6bd9
Step 3 : RUN git clone https://github.com/bjodah/dummypkg.git &&     cd dummypkg &&     conda install conda-build pytest &&     conda build conda-recipe &&     conda install --use-local dummypkg
 ---> Using cache
 ---> 6765cf1fae4d
Step 4 : RUN cd /tmp &&     python -c 'import dummypkg; print(dummypkg.__file__)' &&     python -m pytest --pyargs dummypkg
 ---> Running in e9c721e5c4c2
/opt/conda/lib/python2.7/site-packages/dummypkg-0.1.0-py2.7.egg/dummypkg/__init__.pyc
============================= test session starts ==============================
platform linux2 -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: /tmp, inifile: 

========================= no tests ran in 0.00 seconds =========================
ERROR: file or package not found: dummypkg
INFO[0000] The command [/bin/sh -c cd /tmp &&     python -c 'import dummypkg; print(dummypkg.__file__)' &&     python -m pytest --pyargs dummypkg] returned a non-zero code: 4 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the linked Dockerfile and the python -m pytest --pyargs dummypkg command in the conda environment. Trace pytest's package discovery for the .egg path shown in the output; done means --pyargs discovers tests in zipped packages, unpacked wheels, or eggs instead of reporting that the package is not found.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
cli, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.