Details
Description
The Python standard library's built-in `unittest.mock.patch.dict` feature allows temporarily replacing a module with a mock at import-time, as described at https://docs.python.org/3/library/unittest.mock-examples.html#mocking-imports-with-patch-dict
However, once PySide6 has been imported, trying to use this feature raises AttributeError: __name__ when shibokensupport/feature.py:feature_imported() tries to access __name__ on the mocked module during import.
A similar bug, PYSIDE-1368, was reported and fixed in feature_import() by "feature: ignore if `__name__` does not exist in a module" d02b070e23c757fa72a66a4049a659f4f5c5fc77 https://codereview.qt-project.org/c/pyside/pyside-setup/+/312517 , but it doesn't look like the solution was carried forward into the new code added in commit "feature: heavily rework the context switching" 7377d2b8130ce7290775cd8a343e75c0561fc854 https://codereview.qt-project.org/c/pyside/pyside-setup/+/444454. Perhaps an analogous fix could work here, replacing module.__name__ with getattr(module, '__name__', '__main__')?
Attachments
Issue Links
- relates to
-
PYSIDE-1368 [REG] Documentation build fails
- Closed
-
PYSIDE-1755 __code__ inspection on slot connection is buggy (breaks, e.g. MagicMock testing)
- Closed
-
PYSIDE-2029 snake_case feature impacts loaded module (qasync)
- Closed