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
marker (
str
orpytest.mark.*
object) –append=True
whether to append the marker, ifFalse
insert at position0
.
-
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 of 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 ourself) 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]¶ - 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
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: 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"))
-
-
exception
schrodinger.test.pytest.exetest.
ProcessDied
[source]¶ Bases:
RuntimeError
-
__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.
-
-
exception
schrodinger.test.pytest.exetest.
KilledProcess
[source]¶ Bases:
schrodinger.test.pytest.exetest.ProcessDied
-
__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.
-
-
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=None, capture=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
orpytest.mark.*
object) –append=True
whether to append the marker, ifFalse
insert at position0
.
-
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().
-
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.
-
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.pytest.exetest.
run_subprocess_test
(cmd, timeout, capture, verbose, env, *, memtest_log_files=None)[source]¶ Run the test in a subprocess.
- Parameters
cmd (str or list) – subprocess.Popen command argument
timeout (int) – passed to subprocess.wait
capture (bool) – capture test output
verbose (bool) – pytest verbosity
env (dict) – 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.
-
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
marker (
str
orpytest.mark.*
object) –append=True
whether to append the marker, ifFalse
insert at position0
.
-
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 of 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 ourself) 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]¶ - 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
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: 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"))
-
-
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
marker (
str
orpytest.mark.*
object) –append=True
whether to append the marker, ifFalse
insert at position0
.
-
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"))
-