Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test can't be run without installed package #397

Open
catap opened this issue Apr 7, 2022 · 5 comments · May be fixed by #398
Open

Test can't be run without installed package #397

catap opened this issue Apr 7, 2022 · 5 comments · May be fixed by #398

Comments

@catap
Copy link

catap commented Apr 7, 2022

What did you do?

Try to run tests without installing any version of a package.

What did you expect to happen?

It should works.

What actually happened?

It fails as:

ImportError while importing test module '/opt/local/var/macports/build/_Users_catap_src_macports-ports_python_py-last/py37-last/work/pylast-5.0.0/tests/unicode_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/unicode_test.py:5: in <module>
    import pylast
build/lib/pylast/__init__.py:50: in <module>
    __version__ = importlib_metadata.version(__name__)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/importlib_metadata/__init__.py:978: in version
    return distribution(distribution_name).version
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/importlib_metadata/__init__.py:951: in distribution
    return Distribution.from_name(distribution_name)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/importlib_metadata/__init__.py:542: in from_name
    raise PackageNotFoundError(name)
E   importlib_metadata.PackageNotFoundError: No package metadata was found for pylast

What versions are you using?

  • OS: macOS 12
  • Python: 3.7.13
  • pylast: 5.0.0.
@hugovk
Copy link
Member

hugovk commented Apr 7, 2022

Hello, testing instructions are at https://github.com/pylast/pylast#testing

So for example:

python3 -m pip install -e ".[tests]"
pytest

What exactly did you run?

@catap
Copy link
Author

catap commented Apr 7, 2022

@hugovk but this is installing of packages ;)

@hugovk
Copy link
Member

hugovk commented Apr 7, 2022

Yes, it installs dependencies required for running the tests, plus also it's good practice to test against your installed package instead of one that happens to be local:

Another option: tox :)

@catap
Copy link
Author

catap commented Apr 7, 2022

I’m just try to fix tests inside MacPorts port file: macports/macports-ports#14513

If it fine for you I can try to make small PR which uses n/a as version when it can’t load package info.

catap added a commit to catap/pylast that referenced this issue Apr 7, 2022
Here a naive approach which prevents a fail if this code is used without installing.

Fixes: pylast#397
@catap catap linked a pull request Apr 7, 2022 that will close this issue
@catap
Copy link
Author

catap commented Apr 7, 2022

An example of very similar issue and changes: pycountry/pycountry#52

catap added a commit to catap/pylast that referenced this issue Apr 7, 2022
Here a naive approach which prevents a fail if this code is used without installing.

Fixes: pylast#397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants