-
Notifications
You must be signed in to change notification settings - Fork 718
Update pcieutil error message on loading common pcie module #2786
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
Changes from all commits
da0c1b4
3dc2e21
f8a39e8
b9f2b94
5f1d7cf
b3aedb2
55af02c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from unittest import mock | ||
|
||
from click.testing import CliRunner | ||
from io import StringIO | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
|
@@ -156,6 +157,8 @@ | |
+---------------------+-----------+ | ||
""" | ||
|
||
pcieutil_load_module_warning_msg = "Failed to load platform Pcie module. Warning : No module named 'sonic_platform.pcie', fallback to load Pcie common utility." | ||
|
||
class TestPcieUtil(object): | ||
@classmethod | ||
def setup_class(cls): | ||
|
@@ -199,6 +202,16 @@ def test_aer_option_device(self): | |
result = runner.invoke(pcieutil.cli.commands["pcie-aer"].commands["correctable"], ["-d", "0:1.0"]) | ||
assert result.output == pcieutil_pcie_aer_correctable_dev_output | ||
|
||
def test_load_pcie_module_warning(self): | ||
stdout = sys.stdout | ||
sys.stdout = result = StringIO() | ||
try: | ||
pcieutil.load_platform_pcieutil() | ||
except ImportError: | ||
pass | ||
sys.stdout = stdout | ||
assert pcieutil_load_module_warning_msg not in result.getvalue() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cytsao1 what does this ASSERT confirm? There could be platform which may not see this import Error and in which case this ASSERT may fail? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is to confirm that the import warning message will not be in the console output, whether the Import error is raised or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cytsao1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sys.stdout is updated to be same IO stream as result, so running load_platform_pcieutil output will be captured in result instead of output to console stdout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example of how it would look without this PR
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cytsao1 thanks for clarifying....did not realize that stdout was captured in a string output... |
||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") | ||
|
Uh oh!
There was an error while loading. Please reload this page.