Fix test execution on Bookworm#3041
Merged
yxieca merged 2 commits intosonic-net:bookwormfrom Nov 17, 2023
Merged
Conversation
Running tests with `python3 -m pytest` instead of `python setup.py test` causes some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in the `mock` module between Python 3.9 and Python 3.11. Fix this and make sure it works on both Bullseye and Bookworm.
a3be9bb to
516d70e
Compare
Contributor
Author
|
For |
vdahiya12
approved these changes
Nov 15, 2023
The test_mclag_add_mclag_member_to_nonexisting_domain test case passes when run on Bullseye, but fails on Bookworm. This is because some test cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may persist for other test cases as well, and if test cases happen to run in a different order, then it may unexpectedly fail. For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by setting the value there. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
saiarcot895
added a commit
to saiarcot895/sonic-utilities
that referenced
this pull request
Nov 19, 2023
* Fix test execution on Bookworm Running tests with `python3 -m pytest` instead of `python setup.py test` causes some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in the `mock` module between Python 3.9 and Python 3.11. Fix this and make sure it works on both Bullseye and Bookworm. * Fix mclag_test.py having different results for some test cases The test_mclag_add_mclag_member_to_nonexisting_domain test case passes when run on Bullseye, but fails on Bookworm. This is because some test cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may persist for other test cases as well, and if test cases happen to run in a different order, then it may unexpectedly fail. For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by setting the value there. * Add check_output parameter to the setup function due to the patch Since there is a patched function specified as an attribute, newer versions of mock expect that the object can be passed in as a parameter to the function. However, the `setup` functions didn't accept it as a parameter. Modify the `setup` functions to accept a parameter for this object. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com> --------- Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
lguohan
pushed a commit
that referenced
this pull request
Nov 22, 2023
* Fix test execution on Bookworm Running tests with `python3 -m pytest` instead of `python setup.py test` causes some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in the `mock` module between Python 3.9 and Python 3.11. Fix this and make sure it works on both Bullseye and Bookworm. * Fix mclag_test.py having different results for some test cases The test_mclag_add_mclag_member_to_nonexisting_domain test case passes when run on Bullseye, but fails on Bookworm. This is because some test cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may persist for other test cases as well, and if test cases happen to run in a different order, then it may unexpectedly fail. For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by setting the value there. * Add check_output parameter to the setup function due to the patch Since there is a patched function specified as an attribute, newer versions of mock expect that the object can be passed in as a parameter to the function. However, the `setup` functions didn't accept it as a parameter. Modify the `setup` functions to accept a parameter for this object. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com> --------- Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
nmoray
pushed a commit
to nmoray/sonic-utilities
that referenced
this pull request
Jun 25, 2025
* Fix test execution on Bookworm Running tests with `python3 -m pytest` instead of `python setup.py test` causes some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in the `mock` module between Python 3.9 and Python 3.11. Fix this and make sure it works on both Bullseye and Bookworm. * Fix mclag_test.py having different results for some test cases The test_mclag_add_mclag_member_to_nonexisting_domain test case passes when run on Bullseye, but fails on Bookworm. This is because some test cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may persist for other test cases as well, and if test cases happen to run in a different order, then it may unexpectedly fail. For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by setting the value there. * Add check_output parameter to the setup function due to the patch Since there is a patched function specified as an attribute, newer versions of mock expect that the object can be passed in as a parameter to the function. However, the `setup` functions didn't accept it as a parameter. Modify the `setup` functions to accept a parameter for this object. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com> --------- Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I did
Running tests with
python3 -m pytestinstead ofpython setup.py testcauses some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in themockmodule between Python 3.9 and Python 3.11.Fix this and make sure it works on both Bullseye and Bookworm.
How I did it
Fix mock.patch entries so that the correct object reference gets patched, and remove duplicate test functions in
TestMuxcable.How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)