Hi all. I found something interesting that may be...
# general
w
Hi all. I found something interesting that may be a bug in the coverage component of pytest. Beginning in python 3.10 the "with" statement syntax was changed to allow multiple "with statement" components to be grouped in parentheses:
Copy code
with_stmt          ::=  "with" ( "(" with_stmt_contents ","? ")" | with_stmt_contents ) ":" suite
with_stmt_contents ::=  with_item ("," with_item)*
with_item          ::=  expression ["as" target]
I have a test that uses this format and when I run it with coverage enabled, coverage crashes with something like:
Copy code
Couldn't parse 'mysystem/python/mysystem/server/v2_1/lib/tests/test_zmq_socket_monitor.py' as Python source: 'invalid syntax' at line 480

stderr:



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
If I remove the parentheses from the with statement and instead separate with something like:
Copy code
with A() as a, \
    B() as b, \
    C() as c:
Then the exception goes away. BUILD file has a py constraint of ">=3.10" Encountered in pants 2.23.0. Has anyone else run into this?