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

Filter expected log messages during testing #1014

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Dec 21, 2017

Fixes #1013

Add a filter to the aiida.console StreamHandler to suppress logs during testing

Many tests require the logging of messages to test the functionality
but these messages are not actually required to be read in the
test output and rather just clutter the output and obscure the
actually important error messages.

We add a filter to the console StreamHandler of the aiida logger
which based on the value of the TESTING_MODE setting will suppress
the log record or not. This setting is defined in aiida.settings
and is False by default. In the run_tests method of the verdi devel
command we import the setting and set it to True. This will cause
the filter to swallow all non-important log messages.
Doing this in the run_tests method guarantees that this filter is
only active during the call of verdi devel tests

When passed, the additional output will not be printed
to the console. This is useful when the command line is
tested and we do not want any output to the screen. With
this change we can pass the -q flag to achieve this goal
and the default behavior of the command will remain unchanged
…ng testing

Many tests require the logging of messages to test the functionality
but these messages are not actually required to be read in the
test output and rather just clutter the output and obscure the
actually important error messages.

We add a filter to the console StreamHandler of the aiida logger
which based on the value of the TESTING_MODE setting will suppress
the log record or not. This setting is defined in aiida.settings
and is False by default. In the run_tests method of the verdi devel
command we import the setting and set it to True. This will cause
the filter to swallow all non-important log messages.
Doing this in the run_tests method guarantees that this filter is
only active during the call of verdi devel tests
These temporary local solutions were put in place to suppress
log messages that were fired during testing but that did not
serve a purpose and were merely cluttering the output. With
the newly implemented testing filter for the 'console' logging
handler, these ad hoc solutions are obsolete
@sphuber sphuber changed the title Fix 1013 filter logging during testing Filter expected log messages during testing Dec 21, 2017
Copy link
Contributor

@szoupanos szoupanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aiida/backends/sqlalchemy/tests/migrations.py
also disables logging and we need to remove the relevant code.

@szoupanos
Copy link
Contributor

The aiida/backends/djsite/db/subtests/djangomigrations.py should be also checked.
Thanks a lot!

@szoupanos szoupanos merged commit 3700534 into aiidateam:release_v0.10.1 Dec 21, 2017
@sphuber sphuber deleted the fix_1013_filter_logging_during_testing branch December 22, 2017 11:16
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

Successfully merging this pull request may close these issues.

None yet

2 participants