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

Catching logs of pytest-flake8 plugin #59

Open
GergelyKalmar opened this issue Feb 22, 2017 · 5 comments
Open

Catching logs of pytest-flake8 plugin #59

GergelyKalmar opened this issue Feb 22, 2017 · 5 comments

Comments

@GergelyKalmar
Copy link

When using the pytest-flake8 plugin the flake logs get catched by pytest-catchlog, making it difficult to see the actual flake error output:

`======== FAILURES ========
_______ FLAKE8-check _______
/home/user/Projects/test/test.py:12:5: F841 local variable 'test' is assigned to but never used

-------- Captured log call --------
flake8.options.manager:: DEBUG: Registered option "Option(-v, --verbose, action=count, default=0, dest=verbose, type=None, callback=None, help=Print more information about what is happening in flake8. This option is repeatable and will increase verbosity each time it is repeated., callback=None, callback_args=None, callback_kwargs=None, metavar=None)".
flake8.options.manager:: DEBUG: Registered option "Option(-q, --quiet, action=count, default=0, dest=quiet, type=None, callback=None, help=Report only file names, or nothing. This option is repeatable., callback=None, callback_args=None, callback_kwargs=None, metavar=None)".
... lots of additional flake8 log lines ...
flake8.main.application:: INFO: Finished running
flake8.main.application:: INFO: Reporting errors
flake8.style_guide:: DEBUG: Deciding if "F841" should be reported
flake8.style_guide:: DEBUG: The user configured "F841" to be "Selected.Explicitly", "Selected.Implicitly"
flake8.style_guide:: DEBUG: "F841" will be "Decision.Selected"
flake8.style_guide:: DEBUG: Error(code='F841', filename='/home/user/Projects/test/test.py', line_number=12, column_number=5, text="local variable 'test' is assigned to but never used", physical_line=" test = 'test'\n") is not inline ignored
flake8.main.application:: INFO: Found a total of 1 violations and reported 1
========================`

Is there a possibility to turn off flake8 log catching for an entire pytest session with catchlog or would that be possible to add a command line argument for this?

@GergelyKalmar
Copy link
Author

In case someone is looking for a workaround, there is one. You can disable the 'flake8' logger for the entire session by putting an __init__.py file to the root test path directory with the following content:

from logging import getLogger

getLogger('flake8').propagate = False

@vgavro
Copy link

vgavro commented Apr 18, 2017

Actually I also think that this logger should be disabled by default. It's starting to be headache when dealing with not only checking 'tests', where you can put getLogger('flake8').propagate = False to conftest, but when checking module itself. There should be an option not to propagate some logger names, for example:

    add_option_ini(parser,
               '--log-supress',
               dest='log_supress', default=(''),
               help='supress output from the following logger names, delimited by comma.')
    add_option_ini(parser,
               '--log-only',
               dest='log_only', default=(''),
               help='log output only from the following logger names, delimited by comma.')

@revmischa
Copy link

getLogger('flake8').propagate = False helps (but is pretty annoying to have to add like that)
i get a HUGE amount of logs using pytest-flake8 like:
DEBUG [root] parser.py:346 parsing definition list, current token is tk.NEWLINE (
and i have no idea how to shut them up

@winni2k
Copy link

winni2k commented Dec 16, 2017

I think maybe a more appropriate default logging setting for flake8 would perhaps be 'WARNING'?

@MartinThoma
Copy link

You can simply add a conftest.py with the following content:

import logging


def pytest_configure(config):
    """Flake8 is very verbose by default. Silence it."""
    logging.getLogger("flake8").setLevel(logging.WARNING)

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

No branches or pull requests

5 participants