Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-lsp: Forward a server's stderr output #147

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

alcarney
Copy link
Member

@alcarney alcarney commented Feb 5, 2024

This should be enough in most cases to get pytest to report the server's log output on failure.

There may be issues if there are multiple servers running concurrently/within the same session but we will cross that bridge if/when it becomes an issue.

Closes #143

await super().start_io(cmd, *args, **kwargs)

# Forward the server's stderr to this process' stderr
if self._server and self._server:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking self._server twice. Is this a typo?

Suggested change
if self._server and self._server:
if self._server:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good spot that should be self._server and self._server.stderr:

@alcarney alcarney force-pushed the stderr branch 2 times, most recently from 937515f to 9cd5089 Compare February 7, 2024 20:59
This should be enough in most cases to get pytest to report the
server's log output on failure.

There may be issues if there are multiple servers running
concurrently/within the same session but we will cross that bridge
if/when it becomes an issue.
items = []

for i in range(10):
print(f"Suggesting item {i}", file=sys.stderr, flush=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL stderr was only changed to be line-buffered by default in Python 3.9, so to work in 3.8 we need to set flush=True here

@alcarney alcarney merged commit 46eeb13 into swyddfa:develop Feb 7, 2024
13 checks passed
@alcarney alcarney deleted the stderr branch February 7, 2024 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest-lsp: See server's STDERR in pytest output
2 participants