Skip to content

Commit a4b7ce3

Browse files
committed
docstring wording
1 parent f64e68b commit a4b7ce3

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

unpythonic/syntax/testingtools.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,10 @@ def test(tree, *, args, syntax, expander, **kw): # noqa: F811
201201
to mutate something defined on the outside.
202202
203203
If there is an `expect[expr]` at the top level of the block, the value of
204-
`expr` is what will be asserted. At most one `expect[]` per block; using
205-
both `expect[]` and `return` in the same block is a `SyntaxError`.
204+
`expr` is what will be asserted. There may be at most one `expect[]` per block.
206205
207-
If neither `expect[]` nor `return` is present, the test asserts that the
208-
block completes normally, just like `test[returns_normally(...)]` does
209-
for an expression.
210-
211-
`return expr` continues to work in this position (treated like
212-
`expect[expr]`) but emits a `DeprecationWarning`. **Added in v2.2.0**;
213-
`return` will be un-hijacked in a future major release so that it
214-
regains its standard Python meaning.
206+
If `expect[]` is not present, the test asserts that the block completes
207+
normally, just like `test[returns_normally(...)]` does for an expression.
215208
216209
The asymmetry in syntax reflects the asymmetry between expressions and
217210
statements in Python. Likewise, the fact that `with test` requires
@@ -223,6 +216,18 @@ def test(tree, *, args, syntax, expander, **kw): # noqa: F811
223216
the value of any expressions inside the block. The marks don't have to
224217
be inside `expect[]`; they can appear anywhere.
225218
219+
**Changed in v2.2.0**:
220+
221+
Earlier versions of `unpythonic` used `return expr` instead of `expect[expr]`.
222+
223+
Beginning with v2.2.0, the preferred syntax is `expect[expr]`.
224+
`return expr` continues to work in this position (treated exactly like
225+
`expect[expr]`) but emits a `DeprecationWarning`. `return` will be
226+
un-hijacked in a future major release so that it regains its standard
227+
Python meaning.
228+
229+
Using both `expect[]` and `return` in the same block is a `SyntaxError`.
230+
226231
**Failure and error signaling**:
227232
228233
Upon a test failure, `test[]` will *signal* a `TestFailure` using the

0 commit comments

Comments
 (0)