schrodinger.test.pytest_customizations module¶
Local Schrodinger py.test customizations.
- schrodinger.test.pytest_customizations.register_fixtures(module)¶
Fixtures need to be registered in the pytest_customizations module.
- Parameters
module – module to register pytest.fixture functions
- schrodinger.test.pytest_customizations.pytest_runtestloop(session)¶
- schrodinger.test.pytest_customizations.pytest_runtest_setup(item)¶
- schrodinger.test.pytest_customizations.pytest_runtest_teardown(item, nextitem)¶
- schrodinger.test.pytest_customizations.pytest_addoption(parser)¶
- schrodinger.test.pytest_customizations.pytest_cmdline_main(config)¶
- schrodinger.test.pytest_customizations.pytest_configure(config)¶
- schrodinger.test.pytest_customizations.pytest_sessionstart(session)¶
- schrodinger.test.pytest_customizations.pytest_report_teststatus(report)¶
Put Killed tests into a separate group from other failures.
- schrodinger.test.pytest_customizations.pytest_runtest_makereport(item, call)¶
- schrodinger.test.pytest_customizations.pytest_runtest_logreport(report)¶
- schrodinger.test.pytest_customizations.pytest_collectreport(report)¶
- schrodinger.test.pytest_customizations.pytest_terminal_summary(terminalreporter)¶
- schrodinger.test.pytest_customizations.pytest_sessionfinish(session, exitstatus)¶
- schrodinger.test.pytest_customizations.pytest_unconfigure(config)¶
- schrodinger.test.pytest_customizations.pytest_collect_file(parent, path)¶
Pytest function: Should “path” be collected as a test?
Adds compiled tests.
- schrodinger.test.pytest_customizations.pytest_pycollect_makemodule(path, parent)¶
For all Python test files, use
ModuleWithPatchCheck
instead of the normalpytest.Module
class.
- schrodinger.test.pytest_customizations.pytest_itemcollected(item)¶
Don’t run most Python tests under memtest.
- schrodinger.test.pytest_customizations.pytest_collection_modifyitems(items)¶
- schrodinger.test.pytest_customizations.pytest_collection_finish(session)¶
Work-around for a bad cache of conftest.py
Removes the cache after all tests have been loaded. At this point, all available conftests will also be loaded, so the caching won’t be a problem. Still leaves us vulnerable to incorrect caching during test discovery, though.
- schrodinger.test.pytest_customizations.pytest_addhooks(pluginmanager)¶
Add a hook to designate an owner of each test.
- class schrodinger.test.pytest_customizations.ModuleWithPatchCheck(*k, **kw)¶
Bases:
_pytest.python.Module
A Module collector that makes sure there are no active patches after module import and again after all tests in the module have completed.
- teardown()¶
- name¶
A unique name within the scope of the parent node.
- parent¶
The parent collector node.
- config¶
- session¶
- fspath¶
Filesystem path where this node was collected from (can be None).
- exception CollectError¶
Bases:
Exception
An error during collection, contains a custom message.
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- __init__(fspath: py._path.local.LocalPath, parent=None, config: Optional[_pytest.config.Config] = None, session: Optional[Session] = None, nodeid: Optional[str] = None) None ¶
- add_marker(marker: Union[str, _pytest.mark.structures.MarkDecorator], append: bool = True) None ¶
Dynamically add a marker object to the node.
- Parameters
append – Whether to append the marker, or prepend it.
- addfinalizer(fin: Callable[[], object]) None ¶
Register a function to be called when this node is finalized.
This method can only be called when this node is active in a setup chain, for example during self.setup().
- classnamefilter(name: str) bool ¶
- property cls¶
Python class object this node was collected from (can be None).
- collect() Iterable[Union[_pytest.nodes.Item, _pytest.nodes.Collector]] ¶
Return a list of children (items and collectors) for this collection node.
- classmethod from_parent(parent, *, fspath, **kw)¶
The public constructor.
- funcnamefilter(name: str) bool ¶
- get_closest_marker(name: str, default: Optional[_pytest.mark.structures.Mark] = None) Optional[_pytest.mark.structures.Mark] ¶
Return the first marker matching the name, from closest (for example function) to farther level (for example module level).
- Parameters
default – Fallback return value if no marker was found.
name – Name to filter by.
- gethookproxy(fspath: py._path.local.LocalPath)¶
- getmodpath(stopatmodule: bool = True, includemodule: bool = False) str ¶
Return Python path relative to the containing module.
- getparent(cls: Type[_pytest.nodes._NodeType]) Optional[_pytest.nodes._NodeType] ¶
Get the next parent node (including self) which is an instance of the given class.
- property ihook¶
fspath-sensitive hook proxy used to call pytest hooks.
- property instance¶
Python instance object this node was collected from (can be None).
- isinitpath(path: py._path.local.LocalPath) bool ¶
- isnosetest(obj: object) bool ¶
Look for the __test__ attribute, which is applied by the @nose.tools.istest decorator.
- istestclass(obj: object, name: str) bool ¶
- istestfunction(obj: object, name: str) bool ¶
- iter_markers(name: Optional[str] = None) Iterator[_pytest.mark.structures.Mark] ¶
Iterate over all markers of the node.
- Parameters
name – If given, filter the results by the name attribute.
- iter_markers_with_node(name: Optional[str] = None) Iterator[Tuple[_pytest.nodes.Node, _pytest.mark.structures.Mark]] ¶
Iterate over all markers of the node.
- Parameters
name – If given, filter the results by the name attribute.
- Returns
An iterator of (node, mark) tuples.
- listchain() List[_pytest.nodes.Node] ¶
Return list of all parent collectors up to self, starting from the root of collection tree.
- listextrakeywords() Set[str] ¶
Return a set of all extra keywords in self and any parents.
- listnames() List[str] ¶
- property module¶
Python module object this node was collected from (can be None).
- property nodeid: str¶
A ::-separated string denoting its collection tree address.
- property obj¶
Underlying Python object.
- reportinfo() Tuple[Union[py._path.local.LocalPath, str], int, str] ¶
- repr_failure(excinfo: _pytest._code.code.ExceptionInfo[BaseException]) Union[str, _pytest._code.code.TerminalRepr] ¶
Return a representation of a collection failure.
- Parameters
excinfo – Exception information for the failure.
- setup() None ¶
- warn(warning: Warning) None ¶
Issue a warning for this Node.
Warnings will be displayed after the test session, unless explicitly suppressed.
- Parameters
warning (Warning) – The warning instance to issue.
- Raises
ValueError – If
warning
instance is not a subclass of Warning.
Example usage:
node.warn(PytestWarning("some message")) node.warn(UserWarning("some message"))
Changed in version 6.2: Any subclass of
Warning
is now accepted, rather than onlyPytestWarning
subclasses.
- keywords¶
Keywords/markers collected from all scopes.
- own_markers: List[Mark]¶
The marker objects belonging to this node.
- extra_keyword_matches: Set[str]¶
Allow adding of extra keywords to use for matching.
- class schrodinger.test.pytest_customizations.ForbiddenImportsMetaPathFinder¶
Bases:
object
Prevent certain modules from being imported into the test harness. Currently, only qtpy is forbidden, as it modifies the PyQt6 namespace (and therefore the schrodinger.Qt namespace) to add back in methods that were removed in Qt 6. This could allow tests to pass even if they call non-existent Qt methods.
- FORBIDDEN = ['qtpy']¶
- find_spec(fullname, path=None, target=None)¶