beeware / briefcase

Tools to support converting a Python project into a standalone native application.
https://briefcase.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.48k stars 352 forks source link

Fix test suite on Windows 11 #1823

Closed jdgsmallwood closed 1 month ago

jdgsmallwood commented 1 month ago

Fixes #1805

The test suite failed on Windows 11 on a clean install due to the wrong number of log messages being captured by capsys.

Windows 11 was responding true to the

sys.__stdout__isatty() 

call in the pytest session, and due to the different logic gates around the "started" and "outcome" messages in briefcase/console.py lines 591-629, only the "outcome" message was logged.

This change aligns the logic between the "started" and "outcome" messages to ensure the suite passes on Windows 11.

PR Checklist:

rmartin16 commented 1 month ago

The logic differences between the "started" and "done" messages was intentional. We only want to show the "started" message when the Wait Bar is disabled. However, we want to show the "done" message more often; that includes when the Wait Bar is disabled but also any time a Wait Bar is not transient.

For this issue, I think we need to understand why isatty() is returning True in Pytest on Windows. The expectation is the tests run without a perceived TTY.

jdgsmallwood commented 1 month ago

Thanks for the input Russell, I've got an alternative solution which utilizes os.isatty and this appears to behave on all platforms. I'm continuing to explore why there is a difference between

os.isatty(sys.__stdout__.fileno())  # returns correct expected result
sys.__stdout__.isatty()  # erroneous

on pytest on Windows 11.