Bug 2275262 - python-uranium fails to build with pytest 8: AttributeError: 'NoneType' object has no attribute 'getController'
Summary: python-uranium fails to build with pytest 8: AttributeError: 'NoneType' objec...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-uranium
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-04-16 10:31 UTC by Tomáš Hrnčiar
Modified: 2024-04-16 12:24 UTC (History)
4 users (show)

Fixed In Version: python-uranium-5.6.0-4.fc41
Clone Of:
Environment:
Last Closed: 2024-04-16 12:09:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources python-uranium pull-request 24 0 None None None 2024-04-16 10:56:29 UTC

Description Tomáš Hrnčiar 2024-04-16 10:31:42 UTC
python-uranium fails to build with pytest 8.

=================================== FAILURES ===================================
___________________ TestActiveToolProxy.test_activeToolPanel ___________________

self = <TestActiveToolProxy.TestActiveToolProxy testMethod=test_activeToolPanel>

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
>           TestActiveToolProxy.proxy = ActiveToolProxy()

tests/Bindings/TestActiveToolProxy.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UM.Qt.Bindings.ActiveToolProxy.ActiveToolProxy object at 0x7f6b2fcb94f0>
parent = None

    def __init__(self, parent = None):
        super().__init__(parent)
    
        self._active_tool = None
        self._properties = {}
>       Application.getInstance().getController().activeToolChanged.connect(self._onActiveToolChanged)
E       AttributeError: 'NoneType' object has no attribute 'getController'

UM/Qt/Bindings/ActiveToolProxy.py:22: AttributeError
_______________________ TestActiveToolProxy.test_isValid _______________________

self = <TestActiveToolProxy.TestActiveToolProxy testMethod=test_isValid>

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
>           TestActiveToolProxy.proxy = ActiveToolProxy()

tests/Bindings/TestActiveToolProxy.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UM.Qt.Bindings.ActiveToolProxy.ActiveToolProxy object at 0x7f6b2fcb9c70>
parent = None

    def __init__(self, parent = None):
        super().__init__(parent)
    
        self._active_tool = None
        self._properties = {}
>       Application.getInstance().getController().activeToolChanged.connect(self._onActiveToolChanged)
E       AttributeError: 'NoneType' object has no attribute 'getController'

UM/Qt/Bindings/ActiveToolProxy.py:22: AttributeError
_____________________ TestActiveToolProxy.test_properties ______________________

self = <TestActiveToolProxy.TestActiveToolProxy testMethod=test_properties>

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
>           TestActiveToolProxy.proxy = ActiveToolProxy()

tests/Bindings/TestActiveToolProxy.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UM.Qt.Bindings.ActiveToolProxy.ActiveToolProxy object at 0x7f6b2fcb9e50>
parent = None

    def __init__(self, parent = None):
        super().__init__(parent)
    
        self._active_tool = None
        self._properties = {}
>       Application.getInstance().getController().activeToolChanged.connect(self._onActiveToolChanged)
E       AttributeError: 'NoneType' object has no attribute 'getController'

UM/Qt/Bindings/ActiveToolProxy.py:22: AttributeError
____________________ TestActiveToolProxy.test_triggerAction ____________________

self = <TestActiveToolProxy.TestActiveToolProxy testMethod=test_triggerAction>

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
>           TestActiveToolProxy.proxy = ActiveToolProxy()

tests/Bindings/TestActiveToolProxy.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UM.Qt.Bindings.ActiveToolProxy.ActiveToolProxy object at 0x7f6b2fcba0d0>
parent = None

    def __init__(self, parent = None):
        super().__init__(parent)
    
        self._active_tool = None
        self._properties = {}
>       Application.getInstance().getController().activeToolChanged.connect(self._onActiveToolChanged)
E       AttributeError: 'NoneType' object has no attribute 'getController'

UM/Qt/Bindings/ActiveToolProxy.py:22: AttributeError
________________ TestActiveToolProxy.test_triggerActionWithData ________________

self = <TestActiveToolProxy.TestActiveToolProxy testMethod=test_triggerActionWithData>

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
>           TestActiveToolProxy.proxy = ActiveToolProxy()

tests/Bindings/TestActiveToolProxy.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UM.Qt.Bindings.ActiveToolProxy.ActiveToolProxy object at 0x7f6b2fcba5d0>
parent = None

    def __init__(self, parent = None):
        super().__init__(parent)
    
        self._active_tool = None
        self._properties = {}
>       Application.getInstance().getController().activeToolChanged.connect(self._onActiveToolChanged)
E       AttributeError: 'NoneType' object has no attribute 'getController'

UM/Qt/Bindings/ActiveToolProxy.py:22: AttributeError
=============================== warnings summary ===============================
../../../../usr/lib/python3.12/site-packages/zombie_imp/__init__.py:1
  /usr/lib/python3.12/site-packages/zombie_imp/__init__.py:1: DeprecationWarning: the imp module was removed in favour of importlib. Someone brought it back, but it's not a good idea to use it.
    from .imp_3_11 import *

UM/Settings/SettingFunction.py:245
  /builddir/build/BUILD/Uranium-5.6.0/UM/Settings/SettingFunction.py:245: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
    def visit_Str(self, node: ast.Str) -> None:

../../../../usr/lib/python3.12/site-packages/twisted/web/http.py:103
  /usr/lib/python3.12/site-packages/twisted/web/http.py:103: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    import cgi

tests/Math/TestPolygon.py::TestPolygon::test_mirror[data0]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data1]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data2]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data3]
  /builddir/build/BUILD/Uranium-5.6.0/UM/Math/Polygon.py:132: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    point_matrix = numpy.matrix(self._points)  # type: ignore

tests/Math/TestPolygon.py::TestPolygon::test_mirror[data0]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data1]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data2]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data3]
  /builddir/build/BUILD/Uranium-5.6.0/UM/Math/Polygon.py:145: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    axis_matrix = numpy.matrix(axis_direction) # type: ignore

tests/Math/TestPolygon.py::TestPolygon::test_mirror[data0]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data0]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data1]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data1]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data2]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data2]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data3]
tests/Math/TestPolygon.py::TestPolygon::test_mirror[data3]
  /usr/lib64/python3.12/site-packages/numpy/matrixlib/defmatrix.py:70: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    return matrix(data, dtype=dtype, copy=False)

tests/SaveFile/TestSaveFile.py: 2 warnings
tests/Settings/TestRoundtripping.py: 108 warnings
  /usr/lib64/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=2909) is multi-threaded, use of fork() may lead to deadlocks in the child.
    self.pid = os.fork()

tests/Settings/TestSettingFunction.py::test_init_good["x"]
tests/Settings/TestSettingFunction.py::test_call[data1]
tests/Settings/TestSettingFunction.py::test_getUsedSettings[data1]
tests/Settings/TestSettingFunction.py::test_getUsedSettings[data7]
  /builddir/build/BUILD/Uranium-5.6.0/UM/Settings/SettingFunction.py:278: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
    if node.s.startswith("_"):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

-------------------------------------------------------------------------------------------------------- benchmark: 18 tests --------------------------------------------------------------------------------------------------------
Name (time in ns)                                 Min                       Max                  Mean                StdDev                Median                 IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
benchmark_findDefinitions[filter6-0]         394.7000 (1.0)         82,502.0000 (7.26)       425.1857 (1.0)        238.9420 (2.00)       409.7000 (1.0)        3.0000 (1.65)   2986;11525    2,351.9137 (1.0)      190477          10
benchmark_findDefinitions[filter0-1]         447.1818 (1.13)        16,529.2727 (1.46)       460.9098 (1.08)       125.3115 (1.05)       450.8182 (1.10)       1.8182 (1.0)      547;1931    2,169.6217 (0.92)      46402          11
benchmark_matchesFilter[filter0-True]        573.6000 (1.45)        69,831.6500 (6.15)       605.0116 (1.42)       263.1671 (2.20)       588.1000 (1.44)       5.0500 (2.78)    2175;4997    1,652.8610 (0.70)      81414          20
benchmark_matchesFilter[filter2-True]        683.2500 (1.73)        11,359.3000 (1.0)        715.8959 (1.68)       119.5745 (1.0)        700.8500 (1.71)       8.0500 (4.43)    1668;2165    1,396.8510 (0.59)      52203          20
benchmark_matchesFilter[filter4-False]       807.0000 (2.04)        45,312.6000 (3.99)       840.8040 (1.98)       290.6500 (2.43)       821.0500 (2.00)       5.5500 (3.05)     946;1673    1,189.3378 (0.51)      28990          20
benchmark_matchesFilter[filter1-True]        961.0000 (2.43)       184,877.0000 (16.28)    1,018.5094 (2.40)       645.8831 (5.40)       992.0000 (2.42)      10.0000 (5.50)     357;7812      981.8270 (0.42)     173581           1
benchmark_matchesFilter[filter3-True]      1,653.0000 (4.19)       195,898.0000 (17.25)    1,747.3095 (4.11)     1,106.9505 (9.26)     1,703.0000 (4.16)      11.0000 (6.05)    592;12381      572.3085 (0.24)     157431           1
benchmark_findContainers[query_args0]      5,691.0000 (14.42)    1,213,208.0000 (106.80)   6,161.9697 (14.49)    8,215.5100 (68.71)    5,891.0000 (14.38)    111.0000 (61.05)    280;1083      162.2858 (0.07)      22804           1
benchmark_findContainers[query_args5]      6,031.0000 (15.28)       24,156.0000 (2.13)     6,390.5617 (15.03)    1,509.7874 (12.63)    6,112.0000 (14.92)     61.2500 (33.69)      71;157      156.4808 (0.07)       1565           1
benchmark_findDefinitions[filter2-1]       6,091.0000 (15.43)      941,578.0000 (82.89)    6,421.3433 (15.10)    3,356.9901 (28.07)    6,252.0000 (15.26)     91.0000 (50.05)   1210;2721      155.7307 (0.07)      92765           1
benchmark_findDefinitions[filter3-2]       6,142.0000 (15.56)      205,827.0000 (18.12)    6,445.8188 (15.16)    1,608.1063 (13.45)    6,282.0000 (15.33)     79.0000 (43.45)   1513;3332      155.1393 (0.07)     100211           1
benchmark_findContainers[query_args1]      6,372.0000 (16.14)       63,630.0000 (5.60)     6,764.1621 (15.91)    1,548.0422 (12.95)    6,512.0000 (15.89)     80.0000 (44.00)    925;2240      147.8380 (0.06)      28486           1
benchmark_findDefinitions[filter5-0]       6,382.0000 (16.17)    1,107,521.0000 (97.50)    6,723.0673 (15.81)    6,089.9152 (50.93)    6,552.0000 (15.99)     60.0000 (33.00)    446;1591      148.7416 (0.06)      34790           1
benchmark_findContainers[query_args2]      6,592.0000 (16.70)       58,651.0000 (5.16)     6,915.7834 (16.27)    1,419.8391 (11.87)    6,703.0000 (16.36)     61.0000 (33.55)     208;691      144.5968 (0.06)       7672           1
benchmark_findDefinitions[filter1-3]       6,752.0000 (17.11)      188,554.0000 (16.60)    7,082.6940 (16.66)    1,978.1180 (16.54)    6,883.0000 (16.80)     70.0000 (38.50)   1671;2796      141.1892 (0.06)      70837           1
benchmark_findContainers[query_args3]      7,364.0000 (18.66)      205,075.0000 (18.05)    7,897.0889 (18.57)    1,964.6666 (16.43)    7,684.0000 (18.76)    179.0000 (98.45)    832;1051      126.6289 (0.05)      26660           1
benchmark_findContainers[query_args4]      7,674.0000 (19.44)       60,644.0000 (5.34)     8,077.3449 (19.00)    1,659.7999 (13.88)    7,804.0000 (19.05)     70.9999 (39.05)     290;711      123.8031 (0.05)       8461           1
benchmark_findDefinitions[filter4-3]       8,726.0000 (22.11)      268,705.0000 (23.66)    9,254.8149 (21.77)    2,094.8566 (17.52)    8,997.0000 (21.96)    150.0000 (82.50)   1821;2338      108.0519 (0.05)      61237           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
=========================== short test summary info ============================
FAILED tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_activeToolPanel
FAILED tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_isValid
FAILED tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_properties
FAILED tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerAction
FAILED tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerActionWithData
=== 5 failed, 2377 passed, 10 skipped, 14 deselected, 133 warnings in 20.54s ===

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07310719-python-uranium/

For all our attempts to build python-uranium with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/python-uranium/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. And this bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change
proposal https://fedoraproject.org/wiki/Changes/Pytest_8

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2024-04-16 10:49:40 UTC
With pytest 8, TestActiveToolProxy runs first and fails:


tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_activeToolPanel FAILED [  0%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_isValid FAILED [  0%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_properties FAILED [  0%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerAction FAILED [  0%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerActionWithData FAILED [  0%]
...


With pytest 7, it runs later and suceeds:

...
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_activeToolPanel PASSED [ 34%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_isValid PASSED [ 34%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_properties PASSED [ 34%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerAction PASSED [ 34%]
tests/Bindings/TestActiveToolProxy.py::TestActiveToolProxy::test_triggerActionWithData PASSED [ 34%]
...


The order of the tests seems to matter because Application is a singleton and TestActiveToolProxy assumes something already happened to it (an instance was created).

Upstream has some mechanism that tries to force the order https://github.com/Ultimaker/Uranium/blob/5.7.0/tests/conftest.py#L62 -- but it landed after 5.6.0 which we have packaged in Fedora and cannot yet trivially upgrade.

We could try backporting https://github.com/Ultimaker/Uranium/pull/941


(It hurts me when I see upstream forcing the order of tests rather than fixing the tests not to rely on order, but I don't have the capacity to fix their tests.)

Comment 2 Fedora Update System 2024-04-16 12:20:40 UTC
FEDORA-2024-791723e9b5 (python-uranium-5.6.0-4.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-791723e9b5

Comment 3 Fedora Update System 2024-04-16 12:24:35 UTC
FEDORA-2024-791723e9b5 (python-uranium-5.6.0-4.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.