Python testsuite won't find module despite package in BuildRequires
Hi! The Python package python-azure-devops has been failing to build in Factory for some time and the necessary fixes have so far been fixed in upstream git only but without any new release. I have therefore decided to package a current git snapshot to fix the build problem with the package. However, there is now an issue with the testsuite that I have not been able to sort out [1]: [ 16s] ====================================================================== [ 16s] ERROR: azure.devops.v6_0.work_item_tracking_process_template (unittest.loader._FailedTest) [ 16s] ---------------------------------------------------------------------- [ 16s] ImportError: Failed to import test module: azure.devops.v6_0.work_item_tracking_process_template [ 16s] Traceback (most recent call last): [ 16s] File "/usr/lib64/python3.8/unittest/loader.py", line 470, in _find_test_path [ 16s] package = self._get_module_from_name(name) [ 16s] File "/usr/lib64/python3.8/unittest/loader.py", line 377, in _get_module_from_name [ 16s] __import__(name) [ 16s] File "/home/abuild/rpmbuild/BUILD/azure-devops-7.0.0/azure/devops/v6_0/work_item_tracking_process_template/__init__.py", line 9, in <module> [ 16s] from .models import * [ 16s] File "/home/abuild/rpmbuild/BUILD/azure-devops-7.0.0/azure/devops/v6_0/work_item_tracking_process_template/models.py", line 9, in <module> [ 16s] from msrest.serialization import Model [ 16s] File "/usr/lib/python3.8/site-packages/msrest/__init__.py", line 28, in <module> [ 16s] from .configuration import Configuration [ 16s] File "/usr/lib/python3.8/site-packages/msrest/configuration.py", line 38, in <module> [ 16s] from .universal_http.requests import ( [ 16s] File "/usr/lib/python3.8/site-packages/msrest/universal_http/__init__.py", line 53, in <module> [ 16s] from ..exceptions import ClientRequestError, raise_with_traceback [ 16s] File "/usr/lib/python3.8/site-packages/msrest/exceptions.py", line 31, in <module> [ 16s] from azure.core.exceptions import SerializationError, DeserializationError [ 16s] ModuleNotFoundError: No module named 'azure.core' During the testsuite run, the Python interpreter complains that it cannot import azure.core despite python-azure-core being installed through BuildRequires. When I change into the build root with "osc chroot", I can actually import "azure.core" from an interactive Python instance after running "python38", for example. However, once I have made a testsuite test run with "python38 setup.py test", this no longer works and I am getting the error that is shown during the testsuite run. I have tried setting PYTHONPATH, but that didn't help. Does anyone have a suggestion? I have currently disabled the testsuite in my home project, but I actually want to submit the package with the testsuite remaining enabled. Thanks, Adrian
[1] https://build.opensuse.org/package/show/home:glaubitz:branches:devel:languag...
Hi Adrian, Am 24.03.23 um 14:15 schrieb Adrian Glaubitz via openSUSE Factory:
Hi!
The Python package python-azure-devops has been failing to build in Factory for some time and the necessary fixes have so far been fixed in upstream git only but without any new release.
I have therefore decided to package a current git snapshot to fix the build problem with the package. However, there is now an issue with the testsuite that I have not been able to sort out [1]:
[ 16s] ====================================================================== [ 16s] ERROR: azure.devops.v6_0.work_item_tracking_process_template (unittest.loader._FailedTest) [ 16s] ---------------------------------------------------------------------- [ 16s] ImportError: Failed to import test module: azure.devops.v6_0.work_item_tracking_process_template [ 16s] Traceback (most recent call last): [ 16s] File "/usr/lib64/python3.8/unittest/loader.py", line 470, in _find_test_path [ 16s] package = self._get_module_from_name(name) [ 16s] File "/usr/lib64/python3.8/unittest/loader.py", line 377, in _get_module_from_name [ 16s] __import__(name) [ 16s] File "/home/abuild/rpmbuild/BUILD/azure-devops-7.0.0/azure/devops/v6_0/work_item_tracking_process_template/__init__.py", line 9, in <module> [ 16s] from .models import * [ 16s] File "/home/abuild/rpmbuild/BUILD/azure-devops-7.0.0/azure/devops/v6_0/work_item_tracking_process_template/models.py", line 9, in <module> [ 16s] from msrest.serialization import Model [ 16s] File "/usr/lib/python3.8/site-packages/msrest/__init__.py", line 28, in <module> [ 16s] from .configuration import Configuration [ 16s] File "/usr/lib/python3.8/site-packages/msrest/configuration.py", line 38, in <module> [ 16s] from .universal_http.requests import ( [ 16s] File "/usr/lib/python3.8/site-packages/msrest/universal_http/__init__.py", line 53, in <module> [ 16s] from ..exceptions import ClientRequestError, raise_with_traceback [ 16s] File "/usr/lib/python3.8/site-packages/msrest/exceptions.py", line 31, in <module> [ 16s] from azure.core.exceptions import SerializationError, DeserializationError [ 16s] ModuleNotFoundError: No module named 'azure.core'
During the testsuite run, the Python interpreter complains that it cannot import azure.core despite python-azure-core being installed through BuildRequires.
When I change into the build root with "osc chroot", I can actually import "azure.core" from an interactive Python instance after running "python38", for example. However, once I have made a testsuite test run with "python38 setup.py test", this no longer works and I am getting the error that is shown during the testsuite run.
- There is no python38 command. You probably mean python3.8? setup.py test has been deprecated a long time ago. Use unittest or pytest, we have macros for it. Upstream uses pytest [2] although the single test file [3] is written to work with plain unittest.
I have tried setting PYTHONPATH, but that didn't help.
Does anyone have a suggestion? I have currently disabled the testsuite in my home project, but I actually want to submit the package with the testsuite remaining enabled.
Requires: python-azure-nspkg >= 3.0.0 ... rm -rf %{buildroot}%{$python_sitelib}/azure/__init__.* Did you check if this ist still the correct setup? There is a bunch of namespace techniques in Python which contradict each other when mixed. If the nspkg is still the desired and consistent setup, you probably have to keep the __init__.py in the BUILDROOT for the testsuite and only %exclude the file in the %files section instead of deleting it too early.
Thanks, Adrian
[1] https://build.opensuse.org/package/show/home:glaubitz:branches:devel:languag...
- Ben [2] https://github.com/microsoft/azure-devops-python-api/blob/dev/.github/workfl... [3] https://github.com/microsoft/azure-devops-python-api/blob/dev/azure-devops/a...
Hello Ben! On Fri, 2023-03-24 at 14:55 +0100, Ben Greiner wrote:
- There is no python38 command. You probably mean python3.8?
Yes, obviously. I did run python3.8, of course.
setup.py test has been deprecated a long time ago. Use unittest or pytest, we have macros for it. Upstream uses pytest [2] although the single test file [3] is written to work with plain unittest.
The spec file uses "%pyunittest discover -v" which should be okay. I was just running the testsuite in the chroot for testing reasons using the setup.py command.
I have tried setting PYTHONPATH, but that didn't help.
Does anyone have a suggestion? I have currently disabled the testsuite in my home project, but I actually want to submit the package with the testsuite remaining enabled.
Requires: python-azure-nspkg >= 3.0.0 ... rm -rf %{buildroot}%{$python_sitelib}/azure/__init__.*
Did you check if this ist still the correct setup? There is a bunch of namespace techniques in Python which contradict each other when mixed.
If the nspkg is still the desired and consistent setup, you probably have to keep the __init__.py in the BUILDROOT for the testsuite and only %exclude the file in the %files section instead of deleting it too early.
Thanks for the suggestion. I commented this part out but that didn't help. The testsuite still fails unfortunately. Adrian
participants (2)
-
Adrian Glaubitz
-
Ben Greiner