Skip to content

thermalctld: fix test warnings - #694

Open
fraserg-arista wants to merge 1 commit into
sonic-net:masterfrom
fraserg-arista:master-thermalctld-test-warnings
Open

thermalctld: fix test warnings#694
fraserg-arista wants to merge 1 commit into
sonic-net:masterfrom
fraserg-arista:master-thermalctld-test-warnings

Conversation

@fraserg-arista

Copy link
Copy Markdown
Contributor

Description

  • remove duplicated code for mocking swsscommon
  • add missing method to mocked swsscommon.Table
  • remove a deprecated import

Motivation and Context

Fixes exceptions which produce warnings (and harm test coverage) when running thermalctld tests.

How Has This Been Tested?

Ran thermalctld tests, observed no more warnings.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vvolam
vvolam requested a review from Copilot October 31, 2025 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the test code by removing Python 2 compatibility support and consolidating duplicate mock implementations.

  • Removes deprecated imp.load_source in favor of importlib (Python 3.12+ compatible)
  • Eliminates Python 2/3 conditional imports for the mock module
  • Consolidates duplicate mock code by moving it to a shared location

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sonic-thermalctld/tests/test_thermalctld.py Removes Python 2 compatibility code and replaces deprecated imp.load_source with modern importlib implementation
sonic-thermalctld/tests/mocked_libs/swsscommon/swsscommon.py Adds missing constants and getKeys() method to the shared mock implementation
sonic-thermalctld/tests/mock_swsscommon.py Consolidates duplicate code by importing from the shared mock library instead of duplicating class definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sonic-thermalctld/tests/test_thermalctld.py
Comment thread sonic-thermalctld/tests/mocked_libs/swsscommon/swsscommon.py Outdated
Comment thread sonic-thermalctld/tests/mock_swsscommon.py Outdated
Add a missing method, remove duplicate code, remove a deprecated import.

Signed-off-by: Fraser Gordon <fraserg@arista.com>
@fraserg-arista
fraserg-arista force-pushed the master-thermalctld-test-warnings branch from 3bfbb2e to 0d14e06 Compare February 18, 2026 21:07
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

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.

4 participants