schrodinger.test.perceptualdiff module

Run Perceptual Diff tests in maestrolibs

class schrodinger.test.perceptualdiff.Notify(value)[source]

Bases: enum.Enum

An enumeration.

No = 'no'
Email = 'email'
Terminal = 'terminal'
schrodinger.test.perceptualdiff.get_notification_method()[source]

Get the failure notification method based on username and the SCHRODINGER_IMAGE_DIFF_NOTIFICATION environment variable.

schrodinger.test.perceptualdiff.get_opengl_version_string()[source]
class schrodinger.test.perceptualdiff.PerceptualDiffTest(*k, **kw)[source]

Bases: schrodinger.test.pytest.exetest.ExecutableTest

The tests that use perceptualdiff all require some boilerplate arguments:

-r: path to the result image -v: path to the valid images (without _<number>.png) -d: path to the difference image

__init__(*, name=None, parent=None, valid_path=None, valid_filename=None)[source]

Initialize self. See help(type(self)) for accurate signature.

getCommand()[source]

Build the list command arguments to execute the test.

Parameters

memtest_cmd (list or None) – command string section to make the test run through valgrind.

Returns

list

runtest(env=None)[source]

Executed for each test. (pytest method)

Relegate this to a function that is easier to test.

Parameters
  • env (bool) – Shell environment for subprocess.Popen

  • env – Should output be captured and stored? If not, it goes to stdout.

name
parent
config
session
fspath
add_marker(marker: Union[str, _pytest.mark.structures.MarkDecorator], append: bool = True) → None

dynamically add a marker object to the node.

Parameters

marker (str or pytest.mark.* object) – append=True whether to append the marker, if False insert at position 0.

add_report_section(when: str, key: str, content: str) → None

Adds a new report section, similar to what’s done internally to add stdout and stderr captured output:

item.add_report_section("call", "stdout", "report section contents")
Parameters
  • when (str) – One of the possible capture states, "setup", "call", "teardown".

  • key (str) – Name of the section, can be customized at will. Pytest uses "stdout" and "stderr" internally.

  • content (str) – The full contents as a string.

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().

findValgrindSuppressionsFiles(src_dirname)

Search from the test directory in the source repository to $SCHRODINGER_SRC. Also search $SCHRODINGER_SRC/build_tools.

classmethod from_parent(parent: _pytest.nodes.Node, **kw)

Public Constructor for Nodes

This indirection got introduced in order to enable removing the fragile logic from the node constructors.

Subclasses can use super().from_parent(...) when overriding the construction

Parameters

parent – the parent node of this test Node

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 of no marker was found

  • name – name to filter by

getparent(cls: Type[_NodeType]) → Optional[_NodeType]

get the next parent node (including ourself) which is an instance of the given class

property ihook

fspath sensitive hook proxy used to call pytest hooks

iter_markers(name: Optional[str] = None) → Iterator[_pytest.mark.structures.Mark]
Parameters

name – if given, filter the results by the name attribute

iterate over all markers of the node

iter_markers_with_node(name: Optional[str] = None) → Iterator[Tuple[_pytest.nodes.Node, _pytest.mark.structures.Mark]]
Parameters

name – if given, filter the results by the name attribute

iterate over all markers of the node returns sequence of tuples (node, mark)

listchain() → List[_pytest.nodes.Node]

return list of all parent collectors up to self, starting from root of collection tree.

listextrakeywords() → Set[str]

Return a set of all extra keywords in self and any parents.

listnames() → List[str]
property location
nextitem = None
property nodeid

a ::-separated string denoting its collection tree address.

reportinfo()

The short and long names of the test. (pytest method)

repr_failure(excinfo)

Called when self.runtest() raises an exception. (pytest method)

setup() → None
teardown() → None
warn(warning: PytestWarning) → None

Issue a warning for this item.

Warnings will be displayed after the test session, unless explicitly suppressed

Parameters

warning (Warning) – the warning instance to issue. Must be a subclass of PytestWarning.

Raises

ValueError – if warning instance is not a subclass of PytestWarning.

Example usage:

node.warn(PytestWarning("some message"))
schrodinger.test.perceptualdiff.email_failure_summary(name, valid_path, exc)[source]

Email a summary of the perceptualdiff failure.

schrodinger.test.perceptualdiff.git_summary()[source]

Return a string summarizing the state of the mmshare git repo.