Skip to content

Commit 9a3e552

Browse files
authored
Skip running the tests on Windows Debug. (#292)
* Skip running the tests on Windows Debug. When we run CI on Windows Debug, Python expects to be able to find compiled libraries with an extra _d in their filename that contains the debugging ABI. However, we don't currently have a debug library available for PyQt5, and thus when running under Windows Debug, the tests cannot succeed. While we could build a debug library for PyQt5, that is actually a massive undertaking. Instead, just skip these tests when we are on Windows Debug. While that loses us a bit of coverage, it won't matter much; we are still testing this on Windows (Release) and on Linux. The way in which this patch determines that this is a Windows Debug interpreter is a little chintzy. It just uses the fact that the binary is named python_d.exe to discover that. I couldn't find another way to tell if this was a debug interpreter, but I am open to other ideas. * Update to using importlib.machinery. Thanks to Shane for figuring out this way to tell if we are in a debug interpreter. Signed-off-by: Chris Lalancette <clalancette@gmail.com>
1 parent ce5df8b commit 9a3e552

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

qt_dotgraph/test/dot_to_qt_test.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@
3434
# This file does not pass flake8 due to the raw string literals below.
3535
# flake8: noqa
3636

37+
import importlib.machinery
3738
import subprocess
3839
import sys
3940
import unittest
4041

41-
from python_qt_binding.QtWidgets import QApplication
42-
from qt_dotgraph.dot_to_qt import DotToQtGenerator, get_unquoted
42+
try:
43+
from python_qt_binding.QtWidgets import QApplication
44+
from qt_dotgraph.dot_to_qt import DotToQtGenerator, get_unquoted
45+
qt_import_failed = False
46+
except ImportError:
47+
# If this is running on a Python Windows interpreter built in debug mode, skip running tests
48+
# because we do not have the debug libraries available for PyQt. It is surprisingly tricky to
49+
# discover whether the current interpreter was built in debug mode (note that this is different
50+
# than running the interpreter in debug mode, i.e. PYTHONDEBUG=1). The only non-deprecated way
51+
# we've found is to look for _d.pyd in the extension suffixes, so that is what we do here.
52+
if sys.platform == 'win32' and '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES:
53+
qt_import_failed = True
54+
else:
55+
raise
4356

4457

4558
def check_x_server():
@@ -54,6 +67,7 @@ def check_x_server():
5467
return p.returncode == 0
5568

5669

70+
@unittest.skipIf(qt_import_failed, 'Skipping test on Windows Debug')
5771
class DotToQtGeneratorTest(unittest.TestCase):
5872

5973
DOT_CODE = r'''

0 commit comments

Comments
 (0)