Fix some minor annoyances in Python tests#9132
Merged
greglandrum merged 5 commits intordkit:masterfrom Mar 6, 2026
Merged
Conversation
ricrogz
added a commit
to ricrogz/rdkit
that referenced
this pull request
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I usually work on a Qt-based out-of-tree installation, and this patch addresses some issues in Python tests I have been ignoring for a (long) while:
github4823test is configured to run in-tree, and fails due to a rdkit import error when using an out-of-tree installation withRDK_INSTALL_INTREEdisabled andRDK_INSTALL_PYTHON_TESTSenabled.-Whoops, these aren't meant to be tests, they are functions used by other tests...UnitTestDraw.py::_testMolToFile()andUnitTestDraw.py::_testMolToImage()were not being run due to the test names being prefixed with an underscore. I renamed them and skipped them when Cairo is not available, since they both requireMolToImage()at some point.MolToImage()is not available on Qt builds due to Cairo/Qt incompatibility.PandasTools.py::testGithub1507()(both instances): As explained by the comment,SaveXlsxFromFrame()usesMolToImage()to generate PNG images that are embedded into the Xlsx file, and due to the incompatibility mentioned above, it won't work in Qt-based installations.UnitTestPandasTools.py::test_github2380(): when run underctest -R pythonSourceTests, this test fails in a Qt installation due to a test-test interaction withChem/Draw/UnitTestIPython.py: when runningpythonSourceTests,Chem/Draw/UnitTestIPython.pyruns beforeUnitTestPandasTools.py::test_github2380(). It importsIPythonConsole, which sets up the IPython renderer (which allows avoiding the Qt/Cairo incompatibility by doingDraw.MolsToGridImage = IPythonConsole.ShowMolsand drawing SVGs instead of PNGs), and then uninstalls it as the test ends. Since tests are all run in the same process, whenUnitTestPandasTools.py::test_github2380()runs, thefrom rdkit.Chem.Draw import IPythonConsolecall does not set up the renderer because theIPythonConsolemodule is still loaded, so the init won't trigger again, but since the rendered was uninstalled,Draw.MolsToGridImage()has been restored to the default implementation, which usesMolToImage(), triggering the failure. My fix ensures that the IPython rendered is installed beforePandasTools.FrameToGridImage()is called, and then cleans it up after it runs.