schrodinger.test.pytest.exetest module¶
Support for discovery and running test executables from pytest.
-
class
schrodinger.test.pytest.exetest.
ExecutableFile
(*k, **kw)[source]¶ Bases:
_pytest.nodes.File
A compiled executable file that should be executed as a test.
-
name
¶
-
parent
¶
-
config
¶
-
session
¶
-
fspath
¶
-
exception
CollectError
¶ Bases:
Exception
An error during collection, contains a custom message.
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
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¶ Initialize self. See help(type(self)) for accurate signature.
-
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().
-
classmethod
from_parent
(parent, *, fspath, **kw)¶ The public constructor.
-
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)¶
-
getparent
(cls: Type[_NodeType]) → Optional[_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.
-
isinitpath
(path: py._path.local.LocalPath) → 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
nodeid
¶ A ::-separated string denoting its collection tree address.
-
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¶
-
teardown
() → 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.
-
-
exception
schrodinger.test.pytest.exetest.
ProcessDied
(command: List[str], output: Optional[str], retcode: int)[source]¶ Bases:
RuntimeError
-
__init__
(command: List[str], output: Optional[str], retcode: int)[source]¶ Exception to indicate a process has terminated with a non zero exit code.
- Parameters
command – command line arguments of process
output – stdout/stderr of process, if found
retcode – exit code of process
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
schrodinger.test.pytest.exetest.
ProcessKilled
(command: List[str], output: Optional[str], timeout: int)[source]¶ Bases:
schrodinger.test.pytest.exetest.ProcessDied
-
__init__
(command: List[str], output: Optional[str], timeout: int)[source]¶ Exception to indicate a process has timed out.
- Parameters
command – command line arguments of process
output – stdout/stderr of process, if found
timeout – number of seconds command run before timeout
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
schrodinger.test.pytest.exetest.
ExecutableTest
(*k, **kw)[source]¶ Bases:
_pytest.nodes.Item
Use $SCHRODINGER/run to execute a file with no arguments.
-
__init__
(name, parent=None, **kw)[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
-
findValgrindSuppressionsFiles
(src_dirname)[source]¶ Search from the test directory in the source repository to $SCHRODINGER_SRC. Also search $SCHRODINGER_SRC/build_tools.
-
runtest
(env: Optional[Dict[str, str]] = None, capture: Optional[bool] = None, stdout=None, stderr=None)[source]¶ Executed for each test. (pytest method)
Relegate this to a function that is easier to test.
- Parameters
env (dict) – Shell environment for subprocess.Popen
capture – Should output be captured and stored? If not, it goes to stdout.
stdout (file-like object) – file descriptor, file object, or subprocess special variable for use as stdout argument to subprocess call. Overrides capture if not None.
stderr – file descriptor, file object, or subprocess special variable for use as stderr argument to subprocess call. Overrides capture if not None.
-
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
append – Whether to append the marker, or prepend it.
-
add_report_section
(when: str, key: str, content: str) → None¶ Add 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().
-
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 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 if no marker was found.
name – Name to filter by.
-
getparent
(cls: Type[_NodeType]) → Optional[_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.
-
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
location
¶
-
nextitem
= None¶
-
property
nodeid
¶ A ::-separated string denoting its collection tree address.
-
setup
() → None¶
-
teardown
() → 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.
-
-
schrodinger.test.pytest.exetest.
run_subprocess_test
(cmd: List[str], timeout: Optional[int], capture: bool, verbose: bool, env: Optional[Dict[str, str]], *, memtest_log_files: List[str] = None, stdout=None, stderr=None)[source]¶ Run the test in a subprocess.
- Parameters
cmd – subprocess.Popen command argument
timeout – passed to subprocess.wait
capture – capture test output
verbose – pytest verbosity
env – Shell environment for subprocess.Popen
memtest_log_files (iterable) – iterable with the names of the log files generated by the memtestz, or None if not running a memtest.
stdout (file-like object) – file descriptor, file object, or subprocess special variable for use as stdout argument to subprocess call. Overrides capture if not None.
stderr (file-like object) – file descriptor, file object, or subprocess special variable for use as stderr argument to subprocess call. Overrides capture if not None.
-
class
schrodinger.test.pytest.exetest.
Makefile
(*k, **kw)[source]¶ Bases:
_pytest.nodes.File
-
name
¶
-
parent
¶
-
config
¶
-
session
¶
-
fspath
¶
-
exception
CollectError
¶ Bases:
Exception
An error during collection, contains a custom message.
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
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¶ Initialize self. See help(type(self)) for accurate signature.
-
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().
-
classmethod
from_parent
(parent, *, fspath, **kw)¶ The public constructor.
-
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)¶
-
getparent
(cls: Type[_NodeType]) → Optional[_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.
-
isinitpath
(path: py._path.local.LocalPath) → 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
nodeid
¶ A ::-separated string denoting its collection tree address.
-
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¶
-
teardown
() → 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.
-
-
class
schrodinger.test.pytest.exetest.
MakefileTest
(*k, **kw)[source]¶ Bases:
schrodinger.test.pytest.exetest.ExecutableTest
Run the
make test
target in a directory.-
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]¶ Make on Windows requires the path separator to be “/”, but toplevel turns the SCHRODINGER path into a valid path for the current os. “unfix” the SCHRODINGER path separator.
-
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
append – Whether to append the marker, or prepend it.
-
add_report_section
(when: str, key: str, content: str) → None¶ Add 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 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 if no marker was found.
name – Name to filter by.
-
getparent
(cls: Type[_NodeType]) → Optional[_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.
-
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
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: 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.
-