Skip to content

Commit

Permalink
Merge pull request #134 from abstractfactory/fix133
Browse files Browse the repository at this point in the history
Fix #133
  • Loading branch information
mottosso committed Sep 8, 2016
2 parents b9dff78 + 061925e commit b4c8348
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
14 changes: 11 additions & 3 deletions Qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import os
import sys

__version__ = "0.4.0"
__version__ = "0.4.1"

# All unique members of Qt.py
__added__ = list()
Expand Down Expand Up @@ -239,10 +239,18 @@ def init():
)

for binding in bindings:
log("Trying %s" % binding.__name__[1:], verbose)
log("Trying %s" % binding.__name__, verbose)

try:
sys.modules[__name__] = binding()
binding = binding()

sys.modules.update({
__name__: binding,

# Fix #133, `from Qt.QtWidgets import QPushButton`
__name__ + ".QtWidgets": binding.QtWidgets
})

return

except ImportError as e:
Expand Down
13 changes: 8 additions & 5 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ def binding(binding):
"--exe",
]

# argv.extend(sys.argv[1:])
errors = 0

# Running each test independently via subprocess
# enables tests to filter out from tests.py before
# being split into individual processes via the
# --with-process-isolation feature of nose.
with binding("PyQt4"):
subprocess.call(argv)
errors += subprocess.call(argv)

with binding("PySide"):
subprocess.call(argv)
errors += subprocess.call(argv)

with binding("PyQt5"):
subprocess.call(argv)
errors += subprocess.call(argv)

with binding("PySide2"):
subprocess.call(argv)
errors += subprocess.call(argv)

if errors:
raise Exception("%i binding(s) failed." % errors)
6 changes: 6 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def test_vendoring():
) == 0


def test_import_from_qtwidgets():
"""Fix #133, `from Qt.QtWidgets import XXX` works"""
from Qt.QtWidgets import QPushButton
assert QPushButton.__name__ == "QPushButton", QPushButton


if binding("PyQt4"):
def test_preferred_pyqt4():
"""QT_PREFERRED_BINDING = PyQt4 properly forces the binding"""
Expand Down

0 comments on commit b4c8348

Please sign in to comment.