-
Notifications
You must be signed in to change notification settings - Fork 200
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
Print warning to stdout on load_profile
for development versions
#5311
Merged
sphuber
merged 1 commit into
aiidateam:develop
from
sphuber:fix/5290/load-profile-check-version
Jan 17, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the :mod:`aiida.manage.configuration` module.""" | ||
import pytest | ||
|
||
import aiida | ||
from aiida.manage.configuration import check_version | ||
|
||
|
||
def test_check_version_release(monkeypatch, capsys, isolated_config): | ||
"""Test that ``check_version`` prints nothing for a release version. | ||
|
||
If a warning is emitted, it should be printed to stdout. So even though it will go through the logging system, the | ||
logging configuration of AiiDA will interfere with that of pytest and the ultimately the output will simply be | ||
written to stdout, so we use the ``capsys`` fixture and not the ``caplog`` one. | ||
""" | ||
version = '1.0.0' | ||
monkeypatch.setattr(aiida, '__version__', version) | ||
|
||
# Explicitly setting the default in case the test profile has it changed. | ||
isolated_config.set_option('warnings.development_version', True) | ||
|
||
check_version() | ||
captured = capsys.readouterr() | ||
assert not captured.err | ||
assert not captured.out | ||
|
||
|
||
@pytest.mark.parametrize('suppress_warning', (True, False)) | ||
def test_check_version_development(monkeypatch, capsys, isolated_config, suppress_warning): | ||
"""Test that ``check_version`` prints a warning for a post release development version. | ||
|
||
The warning can be suppressed by setting the option ``warnings.development_version`` to ``False``. | ||
|
||
If a warning is emitted, it should be printed to stdout. So even though it will go through the logging system, the | ||
logging configuration of AiiDA will interfere with that of pytest and the ultimately the output will simply be | ||
written to stdout, so we use the ``capsys`` fixture and not the ``caplog`` one. | ||
""" | ||
version = '1.0.0.post0' | ||
monkeypatch.setattr(aiida, '__version__', version) | ||
|
||
isolated_config.set_option('warnings.development_version', not suppress_warning) | ||
|
||
check_version() | ||
captured = capsys.readouterr() | ||
assert not captured.err | ||
|
||
if suppress_warning: | ||
assert not captured.out | ||
else: | ||
assert f'You are currently using a post release development version of AiiDA: {version}' in captured.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use logger warnings, rather than using click outside of the CLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does use the logging system though. It is true that the module is in the
aiida.cmdline
module, but after the recent refactor, they all go through the logger.