Skip to content

Problem with pkg_resources in pytest 3.0 and Jython #1853

Closed
@raquelalegre

Description

@raquelalegre

I am working on a Jython project that is built with Maven and uses py.test. All was going fine up until the new py.test 3.0 release. I keep on getting this error, which I can't really explain and dissappears if I use py.test<3.0:

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "<string>", line 2, in <module>
  File "/private/tmp/nammu/target/jython-plugins-tmp/build/pytest/pytest.py", line 21, in <module>
    from _pytest.config import (
  File "/private/tmp/nammu/target/jython-plugins-tmp/build/pytest/_pytest/config.py", line 8, in <module>
    import pkg_resources
ImportError: No module named pkg_resources

I have looked briefly in your code and I'll submit a small PR to move the import sentence in _python/config.py to inside the method that uses it. I think that'd solve the problem.

Reproduce like this:

I'm using Maven 3.3.9 and Java 8. In order to reproduce this problem, you can install those and clone my work repo.

git clone https://github.com/oracc/nammu.git
cd nammu

Then run the build:

mvn clean install

This will automatically download the latest py.test (3.0) to be included in the deliverable JAR (plus many other things), and run some tests, which will fail with the above error message.

Note you can get rid of all these downloaded stuff by removing the packages from your maven folder in your home directory called .m2 and the target folder in the clone directory.

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