Skip to content

tolerate UnsupportedOperation in _winconsole._is_console()#1591

Merged
davidism merged 1 commit into
pallets:masterfrom
andy-maier:andy/fix-unsupportedoperation
Jun 26, 2020
Merged

tolerate UnsupportedOperation in _winconsole._is_console()#1591
davidism merged 1 commit into
pallets:masterfrom
andy-maier:andy/fix-unsupportedoperation

Conversation

@andy-maier
Copy link
Copy Markdown
Contributor

@andy-maier andy-maier commented Jun 17, 2020

Details:

  • On Windows, calling 'f.fileno()' in '_winconsole._is_console()' may raise
    UnsupportedOperation, for example when the pytest 'capsys' fixture is used
    which captures stdout for testing purposes.
    This change tolerates that exception and treats it as False.

  • Added a testcase test_echo_with_capsys() where the output of click.echo()
    is captured using the pytest capsys fixture.

fixes #1590

@davidism
Copy link
Copy Markdown
Member

Interesting, thanks for the fix! I think this might address some other issues that have been reported when echoing in IDE consoles.

@andy-maier andy-maier force-pushed the andy/fix-unsupportedoperation branch from 6ba39b3 to f3405fc Compare June 17, 2020 03:25
@davidism davidism added this to the 8.0.0 milestone Jun 24, 2020
@davidism davidism changed the title Fixes #1590: Tolerate UnsupportedOperation in _winconsole._is_console() tolerate UnsupportedOperation in _winconsole._is_console() Jun 24, 2020
* On Windows, calling 'f.fileno()' in '_winconsole._is_console()' may raise
  UnsupportedOperation, for example when the pytest 'capsys' fixture is used
  which captures stdout for testing purposes.

  This change tolerates that exception and treats it as False.

* Added a testcase test_echo_with_capsys() where the output of click.echo()
  is captured using the pytest capsys fixture.

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
@davidism davidism force-pushed the andy/fix-unsupportedoperation branch from f3405fc to ce23ce8 Compare June 26, 2020 00:15
@davidism davidism merged commit 090ff26 into pallets:master Jun 26, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

click.echo() raises UnsupportedOperation on Windows when using pytest capsys

2 participants