Skip to content

Commit 2c63ffa

Browse files
committed
Qt API lazy load in qt_compat and qt_api config option
Fix #129
1 parent aab76c1 commit 2c63ffa

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ New
1111
for ModelTester (`#63`_).
1212

1313
* Now which Qt binding ``pytest-qt`` should use can be configured by the ``qt_api`` config option.
14+
Thanks `@The-Compiler`_ for the request (`#129`_).
1415

16+
.. _#129: https://github.com/pytest-dev/pytest-qt/issues/129
1517
.. _#134: https://github.com/pytest-dev/pytest-qt/issues/134
1618
.. _#63: https://github.com/pytest-dev/pytest-qt/pull/63
1719

tests/test_basics.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,34 @@ def test_parse_ini_boolean_invalid():
277277
import pytestqt.qtbot
278278
with pytest.raises(ValueError):
279279
pytestqt.qtbot._parse_ini_boolean('foo')
280+
281+
282+
@pytest.mark.parametrize('option_api', ['pyqt4', 'pyqt4v2', 'pyqt5', 'pyside'])
283+
def test_qt_api_ini_config(testdir, option_api):
284+
"""
285+
Test qt_api ini option handling.
286+
"""
287+
from pytestqt.qt_compat import qt_api
288+
289+
testdir.makeini("""
290+
[pytest]
291+
qt_api={option_api}
292+
""".format(option_api=option_api))
293+
294+
testdir.makepyfile('''
295+
import pytest
296+
297+
def test_foo(qtbot):
298+
pass
299+
''')
300+
301+
result = testdir.runpytest_subprocess()
302+
if option_api == qt_api.pytest_qt_api:
303+
result.stdout.fnmatch_lines([
304+
'* 1 passed in *'
305+
])
306+
else:
307+
result.stderr.fnmatch_lines([
308+
'*ImportError:*'
309+
])
310+

0 commit comments

Comments
 (0)