schrodinger.test.pytest.sessionfixture module

Fixtures that are encoded into pytest and run as part of each test. These are never explicitly called and only used by test machinery.

schrodinger.test.pytest.sessionfixture.patch_os_environ()[source]

Some tests modify os.environ. We don’t want to allow that to cause test-test interactions

schrodinger.test.pytest.sessionfixture.ensure_maestro_idempotent()[source]
schrodinger.test.pytest.sessionfixture.ensure_JOB_SERVER_idempotent()[source]
schrodinger.test.pytest.sessionfixture.ensure_LAST_EXCEPTION_cleared()[source]
schrodinger.test.pytest.sessionfixture.disable_multiprocessing(monkeypatch)[source]

Disable multiprocessing.Pool in all tests. This was causing memory issues in certain cases. Any test that tries to access multiprocessing.Pool will get an AttributeError when run.

schrodinger.test.pytest.sessionfixture.assert_mmffld_terminated(request)[source]

For any future instantiations of different force fields (that is, with different custom default or custom parameters), mmffld is required to be fully terminated. The fixture here confirms that the global mmffld ref count has been brought back down to 0 at the end of each test.

schrodinger.test.pytest.sessionfixture.disable_show()[source]

Change show() to a no-op for common top-level windows to reduce number of widgets that appear while running tests.

schrodinger.test.pytest.sessionfixture.disable_qmessagebox()[source]

Change QMessageBox to raise RuntimeError so they won’t hang the test harness opaquely.

schrodinger.test.pytest.sessionfixture.prevent_jobdirdlg_jobhub_connection()[source]

Prevent jobdirdlg from connecting to the jobhub callback. Connecting to this callback in multiple unit tests causes issues on Windows builds due to the short periodicity of the callback.

schrodinger.test.pytest.sessionfixture.use_mmpref_sandbox(tmpdir_factory)[source]

Sets preferences (backed by QSettings) to a unique file. Allows parallel xdist tests to not stomp on each other.

schrodinger.test.pytest.sessionfixture.task_wait_with_default_timeout()[source]

Set a default timeout when waiting on tasks in tests. If the default timeout is hit, then raise an error.

schrodinger.test.pytest.sessionfixture.task_cleanup_tmpdirs()[source]

Clean up all tempdirs created by tasks.

schrodinger.test.pytest.sessionfixture.fail_on_running_tasks()[source]

Global fixture that checks to make sure there are no tasks still running after each unit test completes. If there are, this fixture will attempt to kill/stop the tasks before raising an exception.

For tests that need to mock task.run, see the fixture mock_task_helper.

Raises

RuntimeError – If any tasks are running at the end of the unittest

schrodinger.test.pytest.sessionfixture.disallow_mock_in_swig(request)[source]
schrodinger.test.pytest.sessionfixture.delete_job_manager(request)[source]
schrodinger.test.pytest.sessionfixture.force_no_run_in_dir(pytestconfig)[source]

Change back to the original working directory. The cwd is modified by the stupid run-in-dir option to our pytest for mmshare code (to be removed in PYTHON-3408), but this fixture this overrides that.

schrodinger.test.pytest.sessionfixture.check_current_thread_is_main_thread()[source]

Raise an exception if the current thread is not the main thread

schrodinger.test.pytest.sessionfixture.start_qapp(config)[source]

Start a qapp in this process.

schrodinger.test.pytest.sessionfixture.runtest_setup(item)[source]

Execute each test in the directory where the test file lives.

Capture exceptions that occur outside of the main thread (for instance in event loops).

class schrodinger.test.pytest.sessionfixture.Timer[source]

Bases: PyQt5.QtCore.QTimer

Subclass of QTimer that stores all timers so they can be stopped at the end of each test

classmethod singleShot(int, PYQT_SLOT)[source]
classmethod singleShot(int, Qt.TimerType, PYQT_SLOT) None
start(self, int)[source]
start(self) None
__init__(*args, **kwargs)
blockSignals(self, bool) bool
childEvent(self, QChildEvent)
children(self) List[QObject]
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

destroyed(self, object: QObject = None) [signal]

disconnect(QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChild(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
inherits(self, str) bool
installEventFilter(self, QObject)
interval(self) int
isActive(self) bool
isSignalConnected(self, QMetaMethod) bool
isSingleShot(self) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, int)
metaObject(self) QMetaObject
moveToThread(self, QThread)
objectName(self) str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) QObject
property(self, str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, PYQT_SIGNAL) int
remainingTime(self) int
removeEventFilter(self, QObject)
sender(self) QObject
senderSignalIndex(self) int
setInterval(self, int)
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) bool
setSingleShot(self, bool)
setTimerType(self, Qt.TimerType)
signalsBlocked(self) bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
stop(self)
thread(self) QThread
timeout

timeout(self) [signal]

timerEvent(self, QTimerEvent)
timerId(self) int
timerType(self) Qt.TimerType
tr(self, str, disambiguation: str = None, n: int = - 1) str
schrodinger.test.pytest.sessionfixture.stop_all_timers()[source]

Stop all running Timer objects

schrodinger.test.pytest.sessionfixture.runtest_teardown(item, nextitem)[source]