test_qdesktopservice_split.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """Test QDesktopServices split in Qt5."""
  2. from __future__ import absolute_import
  3. import pytest
  4. import warnings
  5. from qtpy import PYQT4, PYSIDE
  6. def test_qstandarpath():
  7. """Test the qtpy.QStandardPaths namespace"""
  8. from qtpy.QtCore import QStandardPaths
  9. assert QStandardPaths.StandardLocation is not None
  10. # Attributes from QDesktopServices shouldn't be in QStandardPaths
  11. with pytest.raises(AttributeError) as excinfo:
  12. QStandardPaths.setUrlHandler
  13. def test_qdesktopservice():
  14. """Test the qtpy.QDesktopServices namespace"""
  15. from qtpy.QtGui import QDesktopServices
  16. assert QDesktopServices.setUrlHandler is not None
  17. @pytest.mark.skipif(not (PYQT4 or PYSIDE), reason="Warning is only raised in old bindings")
  18. def test_qdesktopservice_qt4_pyside():
  19. from qtpy.QtGui import QDesktopServices
  20. # Attributes from QStandardPaths should raise a warning when imported
  21. # from QDesktopServices
  22. with warnings.catch_warnings(record=True) as w:
  23. # Cause all warnings to always be triggered.
  24. warnings.simplefilter("always")
  25. # Try to import QtHelp.
  26. QDesktopServices.StandardLocation
  27. assert len(w) == 1
  28. assert issubclass(w[-1].category, DeprecationWarning)
  29. assert "deprecated" in str(w[-1].message)