test: replace unittest.skip decorators with pytest equivalents#6570
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a test framework compatibility issue where unittest-style skip decorators (unittest.skipIf, unittest.skip) were incorrectly marking tests as FAILED instead of SKIPPED when running non-unittest.TestCase classes with pytest. The changes replace all unittest skip decorators with their pytest equivalents (pytest.mark.skipif, pytest.mark.skip).
Key changes:
- Replaced
unittest.skipIfandunittest.skipdecorators withpytest.mark.skipifandpytest.mark.skipthroughout the test suite - Updated helper functions that returned unittest skip decorators to return pytest skip markers instead
- Added
reasonparameter to all skip decorators for better test output clarity
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unittests/helpers.py | Removed skipIf alias to unittest.skipIf and updated all helper functions to return pytest.mark.skipif instead |
| tests/unittests/test_util.py | Replaced unittest.skipIf decorators with pytest.mark.skipif on test classes and methods, removed import of skipIf helper |
| tests/unittests/sources/test_smartos.py | Replaced skipIf decorator with pytest.mark.skipif, removed import of skipIf helper |
| tests/unittests/sources/test_azure_helper.py | Replaced unittest.skip decorators with pytest.mark.skip |
| tests/unittests/config/test_cc_chef.py | Replaced skipIf decorators with pytest.mark.skipif, removed import of skipIf helper |
| tests/unittests/test_templating.py | Fixed unrelated bug where tmp_path was being called as a function instead of using path concatenation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b906954 to
db964bd
Compare
Issue: When running tests with pytest, unittest-style skip decorators raise unittest.case.SkipTest exceptions which pytest interprets as FAILED rather than SKIPPED on non-unittest.TestCase classes. This caused tests to incorrectly show as failures. Replace unittest.skipIf/skip with pytest.mark.skipif/skip to prevent SkipTest exceptions from being treated as test failures. Fixes canonicalGH-6569
db964bd to
97b5f81
Compare
97b5f81 to
689cb65
Compare
cjp256
left a comment
There was a problem hiding this comment.
LGTM! Cade was just working on the azure tests to ensure they run - can follow after this PR merges.
|
Thanks @cjp256 since these test changes affect a few PRs in flight, let's merge this so affected developers can rebase and pull in the 'fixes'. |
Proposed Commit Message
See commit descriptions
test: fix bug in tmp_path used as a callable for path join operation
test: replace unittest.skip decoartors with pytest equivalents
Issue: When running tests with pytest, unittest-style skip decorators raise unittest.case.SkipTest exceptions which pytest interprets as FAILED rather than SKIPPED on non-unittest.TestCase classes. This caused tests to incorrectly show as failures.
Replace unittest.skipIf/skip with pytest.mark.skipif/skip to prevent SkipTest exceptions from being treated as test failures.
Fixes GH-6569
tests/unittests/Additional Context
CI build failure reproducing this issue
Test Steps
Merge type