Skip to content

-o log_cli=true breaks code because of isatty #13461

Description

@not-my-profile
import logging

def test_demo():
    root_logger = logging.getLogger()

    for handler in root_logger.handlers:
        if isinstance(handler, logging.StreamHandler):
            print(handler.stream.__class__.__mro__)
            if handler.stream.isatty():
                pass

Running this with pytest -o log_cli=true fails with:

>               if handler.stream.isatty():
                   ^^^^^^^^^^^^^^^^^^^^^^^
E               TypeError: 'bool' object is not callable

Apparently because _pytest.terminal.TerminalReporter wrongly implements IOBase.isatty.

self.isatty = file.isatty()

isatty should be a method not an attribute.

Activity

  1. added 9 commits that reference this issue on Jun 2, 2025
    3cf70bc
    f87e547
    f859e46
    18b5524
    8a0687a
    a92c4c6
    9b1085c
    3af5c0a
    d3ddfec
  2. added a commit that references this issue on Jun 2, 2025
    cba5c4a
  3. added a commit that references this issue on Jun 3, 2025
    511e566
  4. added a commit that references this issue on Jun 3, 2025
    b49745e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions