On 12/9/20 10:43 PM, Kai A. Hiller wrote:
Hi,
I'm the maintainer of a python package that uses pytest and the pytest plugin
pytest-django (python-authlib). Under %check I currently run `%{python3} -m
pytest tests/core` to execute the tests. Now I wanted to do the right thing and
change that line to the %pytest macro (`%pytest tests/core`) and that failed:
ModuleNotFoundError: No module named 'tests'
ImportError: No module named 'tests'
pytest-django could not find a Django project (no manage.py file could be
found). You must explicitly add your Django project to the Python
path to have it picked up.
I think the macro and the plugin are interfering here. Is there something that
has to be changed in my spec file, the plugin or the
macro itself to make it work? Should I just keep it the way it is?
It seem that the tests require current working directory to be on the Python
path. `%{python3} -m pytest` does that, `%pytest` doesn't -- because usually you
want to avoid that (to actually import the code from %{python3_site(lib|arch)}
instead of $PWD). In this case, where it cannot be avoided, you can try either:
PYTHONPATH=$PWD %pytest
Or keep using `%{python3} -m pytest`. But note that `%pytest` also sets other
useful environment variables.
--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx