Examples¶
examples
¶
The checked examples of a literate module.
A fence written ```qvr example holds the steps of an example:
let bindings and expect lines that state an expected result of the
module's code. Each such fence is a test of the module the document tangles
to (quivers.testing), named after the document and the fence's line, and
its steps keep their document lines, so a failure names the line of the
expectation that failed.
document_examples
¶
document_examples(text: str, label: str) -> tuple[TestDecl, ...]
The examples a literate document's qvr example fences declare.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The document.
TYPE:
|
label
|
The document's path, which names each example and its diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[TestDecl, ...]
|
One |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a fence's body is not a sequence of example steps, located at the fence. |
Source code in src/quivers/literate/examples.py
literate_source
¶
literate_source(path: Path) -> tuple[bytes, tuple[TestDecl, ...]]
Read a literate module as the test runner reads a module file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[bytes, tuple[TestDecl, ...]]
|
The source it tangles to, and the examples its example fences declare. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If an example fence does not hold example steps. |