Skip to content

Commit

Permalink
Merge pull request #260 from dalthviz/fixes_issue_257
Browse files Browse the repository at this point in the history
PR: Reorganize `QtCharts` module import and add missing skip validation for `QtNetworkAuth` test with `PyQt6`
  • Loading branch information
ccordoba12 authored Oct 22, 2021
2 parents cac88c7 + bc9bddb commit 883caca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 12 additions & 4 deletions qtpy/QtCharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@

if PYQT5:
try:
from PyQt5 import QtChart as QtCharts
from PyQt5.QtChart import *
except ImportError:
raise PythonQtError('The QtChart module was not found. '
'It needs to be installed separately for PyQt5.')
elif PYQT6:
from PyQt6 import QtCharts
try:
from PyQt6.QtCharts import *
except ImportError:
raise PythonQtError('The QtCharts module was not found. '
'It needs to be installed separately for PyQt6.')
elif PYSIDE6:
from PySide6 import QtCharts
from PySide6.QtCharts import *
elif PYSIDE2:
from PySide2.QtCharts import *
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.QtCharts as __temp
import inspect
for __name in inspect.getmembers(__temp.QtCharts):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
3 changes: 2 additions & 1 deletion qtpy/tests/test_qtcharts.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest

from qtpy import PYSIDE2, PYSIDE6


@pytest.mark.skipif(not (PYSIDE2 or PYSIDE6), reason="Only available by default in PySide")
def test_qtcharts():
"""Test the qtpy.QtCharts namespace"""
from qtpy import QtCharts
assert QtCharts.QtCharts.QChart is not None
assert QtCharts.QChart is not None
6 changes: 4 additions & 2 deletions qtpy/tests/test_qtnetworkauth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
from qtpy import PYQT5, PYQT6, PYSIDE2, PYSIDE6

@pytest.mark.skipif(PYSIDE2 or PYQT5, reason="Not available in CI")
from qtpy import PYQT5, PYQT6, PYSIDE2

@pytest.mark.skipif(PYQT5 or PYQT6 or PYSIDE2,
reason="Not available by default in PyQt. Not available for PySide2")
def test_qtnetworkauth():
"""Test the qtpy.QtNetworkAuth namespace"""
from qtpy import QtNetworkAuth
Expand Down

0 comments on commit 883caca

Please sign in to comment.