8000 `-o log_cli=true` breaks code because of isatty · Issue #13461 · pytest-dev/pytest · GitHub
[go: up one dir, main page]

Skip to content
-o log_cli=true breaks code because of isatty #13461
@not-my-profile

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.

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

      0