Skip to content

Commit b4c8348

Browse files
authored
Merge pull request #134 from abstractfactory/fix133
Fix #133
2 parents b9dff78 + 061925e commit b4c8348

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Qt.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import os
3232
import sys
3333

34-
__version__ = "0.4.0"
34+
__version__ = "0.4.1"
3535

3636
# All unique members of Qt.py
3737
__added__ = list()
@@ -239,10 +239,18 @@ def init():
239239
)
240240

241241
for binding in bindings:
242-
log("Trying %s" % binding.__name__[1:], verbose)
242+
log("Trying %s" % binding.__name__, verbose)
243243

244244
try:
245-
sys.modules[__name__] = binding()
245+
binding = binding()
246+
247+
sys.modules.update({
248+
__name__: binding,
249+
250+
# Fix #133, `from Qt.QtWidgets import QPushButton`
251+
__name__ + ".QtWidgets": binding.QtWidgets
252+
})
253+
246254
return
247255

248256
except ImportError as e:

run_tests.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ def binding(binding):
3232
"--exe",
3333
]
3434

35-
# argv.extend(sys.argv[1:])
35+
errors = 0
3636

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

4444
with binding("PySide"):
45-
subprocess.call(argv)
45+
errors += subprocess.call(argv)
4646

4747
with binding("PyQt5"):
48-
subprocess.call(argv)
48+
errors += subprocess.call(argv)
4949

5050
with binding("PySide2"):
51-
subprocess.call(argv)
51+
errors += subprocess.call(argv)
52+
53+
if errors:
54+
raise Exception("%i binding(s) failed." % errors)

tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ def test_vendoring():
159159
) == 0
160160

161161

162+
def test_import_from_qtwidgets():
163+
"""Fix #133, `from Qt.QtWidgets import XXX` works"""
164+
from Qt.QtWidgets import QPushButton
165+
assert QPushButton.__name__ == "QPushButton", QPushButton
166+
167+
162168
if binding("PyQt4"):
163169
def test_preferred_pyqt4():
164170
"""QT_PREFERRED_BINDING = PyQt4 properly forces the binding"""

0 commit comments

Comments
 (0)