Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 7a81539

Browse files
committed
Stabilise state during Parser.consume assert
py.test emits a warning when state is modified during an assert, as py.test attempts to inspect the variables within an assert. Also add a docstring for Parser.consume.
1 parent d0022d8 commit 7a81539

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pep257.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def __call__(self, filelike, filename):
268268
line = property(lambda self: self.stream.line)
269269

270270
def consume(self, kind):
271-
assert self.stream.move().kind == kind
271+
"""Consume one token and verify it is of the expected kind."""
272+
next_token = self.stream.move()
273+
assert next_token.kind == kind
272274

273275
def leapfrog(self, kind, value=None):
274276
"""Skip tokens in the stream until a certain token kind is reached.

0 commit comments

Comments
 (0)