diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-03-21 16:54:59 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-04-11 14:50:13 +0000 |
commit | a44b5721ea945225fae1b77053a6a38de13065dc (patch) | |
tree | cf296078d631135c2662acd3ec85a8052405897a | |
parent | 1db084fbec82be506c0cab865eb9709e37dcd78f (diff) |
Fix qstandarditemmodel_test.py not finding shiboken on macOS
When running make test inside the build folder of PySide2,
the mentioned test failed because it couldn't find shiboken2.
Make sure to import the module as standalone, so the test
succeeds.
Also make sure to specify the proper python paths, by computing
the paths to shiboken and pysidetest from the pyside build root
path, rather than from pysidetest build path, because on some
CMake implementations it evaluates to an empty path (probably
due to the fact that ${pysidetest_BINARY_DIR} is evaluated
before the pysidetest project is actually added).
Change-Id: Ibe86b0d7c2c66db708bba2ffc32b02e5c3e91c79
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/QtWidgets/qstandarditemmodel_test.py | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8aa265ba..1a47f21d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,7 @@ else() # tests/QtWidgets/qstandarditemmodel_test.py needs shiboken2 if(WIN32) - set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${pysidetest_BINARY_DIR};${pysidetest_BINARY_DIR}/../../../shiboken2/shibokenmodule;$ENV{PYTHONPATH}") + set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${CMAKE_BINARY_DIR}/tests/pysidetest;${CMAKE_BINARY_DIR}/../shiboken2/shibokenmodule;$ENV{PYTHONPATH}") set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};${SHIBOKEN_INCLUDE_DIR}/../../bin;$ENV{PATH}") set(LIBRARY_PATH_VAR "PATH") string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}") @@ -16,7 +16,7 @@ else() string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}") string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}") else() - set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util:${pysidetest_BINARY_DIR}:${pysidetest_BINARY_DIR}/../../../shiboken2/shibokenmodule:$ENV{PYTHONPATH}") + set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util:${CMAKE_BINARY_DIR}/tests/pysidetest:${CMAKE_BINARY_DIR}/../shiboken2/shibokenmodule:$ENV{PYTHONPATH}") set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR}:${pysidetest_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}") set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH") endif() diff --git a/tests/QtWidgets/qstandarditemmodel_test.py b/tests/QtWidgets/qstandarditemmodel_test.py index 9ee00726..2e9d260a 100644 --- a/tests/QtWidgets/qstandarditemmodel_test.py +++ b/tests/QtWidgets/qstandarditemmodel_test.py @@ -35,10 +35,15 @@ try: # the normal call with installed PySide2 from PySide2 import shiboken2 as shiboken except ImportError: - # sys.path is set a bit weird during tests, so we help a little to find shiboken2. - sys.path.append("../../..") - # the special call with testrunner.py - from shiboken2.shibokenmodule import shiboken2 as shiboken + try: + # When running make test on macOS, shiboken2 is not part of the PySide2 module, + # so it needs to be imported as a standalone module. + import shiboken2 as shiboken + except ImportError: + # sys.path is set a bit weird during tests, so we help a little to find shiboken2. + sys.path.append("../../..") + # the special call with testrunner.py + from shiboken2.shibokenmodule import shiboken2 as shiboken from helper import UsesQApplication |