Conversation
There was a problem hiding this comment.
Pull request overview
This pull request removes the unittest module dependency across the test suite, converting test classes from unittest.TestCase subclasses to plain classes. The changes also update decorator patterns from unittest to pytest equivalents and remove unittest.main() calls from test files.
Changes:
- Removed
import unitteststatements from all test files - Converted test classes from inheriting
unittest.TestCaseto plain classes - Replaced
unittestdecorators withpytestequivalents (@unittest.skipIf→@pytest.mark.skipif,@unittest.skip→@pytest.mark.skip) - Removed
unittest.main()calls from test entry points
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unittests/test_version.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_susceptibility_distribution.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_schema_imports.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_properties_and_attributes.py | Removed unittest import and converted test classes to plain classes |
| tests/unittests/test_mortality_distribution.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_migration_imports.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_individual_properties.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_fertility_distribution.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_demographics_imports.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_config_imports.py | Removed unittest import and converted test class to plain class |
| tests/unittests/test_age_distribution.py | Removed unittest import and converted test class to plain class |
| tests/test_weather_files.py | Removed unittest import and converted test classes to plain classes |
| tests/test_spatial_reports.py | Removed unittest import and converted test classes to plain classes |
| tests/test_serialization.py | Replaced unittest decorators with pytest equivalents and converted test classes |
| tests/test_property_reports.py | Removed unittest import and converted test classes to plain classes |
| tests/test_node.py | Removed unittest import, converted test class, and removed unittest.main() call |
| tests/test_migration.py | Removed unittest import, converted test class, and removed unittest.main() call |
| tests/test_demog_send_over_pipes.py | Replaced unittest decorators with pytest equivalents and converted test class |
| tests/test_demog.py | Removed unittest import and converted test classes to plain classes |
| tests/test_config_demog.py | Removed unittest import, converted test class, and removed unittest.main() call |
| tests/test_config.py | Removed unittest import, converted test classes, and removed unittest.main() call |
| tests/test_channel_reports.py | Replaced unittest decorator with pytest equivalent and converted test classes |
| tests/test_campaign_module.py | Removed unittest import, converted test class, and removed unittest.main() call |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class IndividualPropertiesTest(): | ||
| def test_default_parameters_to_dict(self): | ||
| individual_property = IndividualProperty(property='blah', values=["blah1", "blah2"]) | ||
| self.assertDictEqual(individual_property.to_dict(), {'Property': 'blah', "Values": ["blah1", "blah2"]}) # empty, no keys/values added |
There was a problem hiding this comment.
The code uses self.assertDictEqual() which is a unittest assertion method, but the class no longer inherits from unittest.TestCase. This will cause an AttributeError at runtime. Replace with pytest assertions like assert individual_property.to_dict() == {'Property': 'blah', 'Values': ['blah1', 'blah2']}.
tests/test_serialization.py
Outdated
|
|
||
| @unittest.skipIf(skip_tests, "Skipping old tests to focus on V6") | ||
| class TestReadVersionOne(unittest.TestCase): | ||
| @pytest.mark.skipif(skip_tests, "Skipping old tests to focus on V6") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires a condition and a reason parameter. The correct syntax is @pytest.mark.skipif(skip_tests, reason='Skipping old tests to focus on V6'). Missing the reason= keyword will cause the decorator to fail.
tests/test_serialization.py
Outdated
| return | ||
|
|
||
| @unittest.skipUnless(support.SNAPPY_SUPPORT, "No Snappy [de]compression support.") | ||
| @pytest.mark.skipif(not support.SNAPPY_SUPPORT, "No Snappy [de]compression support.") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(not support.SNAPPY_SUPPORT, reason='No Snappy [de]compression support.').
tests/test_serialization.py
Outdated
| return | ||
|
|
||
| @unittest.skipIf(support.SNAPPY_SUPPORT, "If Snappy support, test should not raise a UserWarning") | ||
| @pytest.mark.skipif(support.SNAPPY_SUPPORT, "If Snappy support, test should not raise a UserWarning") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(support.SNAPPY_SUPPORT, reason='If Snappy support, test should not raise a UserWarning').
tests/test_serialization.py
Outdated
|
|
||
|
|
||
| @unittest.skipIf(skip_tests, "Skipping old tests to focus on V6") | ||
| @pytest.mark.skipif(skip_tests, "Skipping old tests to focus on V6") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(skip_tests, reason='Skipping old tests to focus on V6').
| @unittest.skipIf(support.SNAPPY_SUPPORT, "If Snappy support, test should not raise a UserWarning") | ||
| @pytest.mark.skipif(support.SNAPPY_SUPPORT, "If Snappy support, test should not raise a UserWarning") | ||
| def test_reading_compressed_file_exception(self): | ||
| with self.assertRaises(UserWarning): |
There was a problem hiding this comment.
The code uses self.assertRaises() which is a unittest context manager, but the class no longer inherits from unittest.TestCase. This will cause an AttributeError at runtime. Replace with pytest's with pytest.raises(UserWarning):.
| with self.assertRaises(UserWarning): | |
| with pytest.raises(UserWarning): |
| print(f"Total of nodes: {cls.large_expected['Metadata']['NodeCount']} ... file size is aprox 54 MB") | ||
|
|
||
| @unittest.skipIf(thisplatform.startswith("win"), "Not valid on Windows") | ||
| @pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(thisplatform.startswith('win'), reason='Not valid on Windows').
| os.remove(tmpfile) | ||
|
|
||
| @unittest.skipIf(thisplatform.startswith("win"), "Not valid on Windows") | ||
| @pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(thisplatform.startswith('win'), reason='Not valid on Windows').
| print("Child method - Done..") | ||
|
|
||
| @unittest.skipIf(thisplatform.startswith("win"), "Not valid on Windows") | ||
| @pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows") |
There was a problem hiding this comment.
The pytest.mark.skipif decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skipif(thisplatform.startswith('win'), reason='Not valid on Windows').
| @pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows") | |
| @pytest.mark.skipif(thisplatform.startswith("win"), reason="Not valid on Windows") |
| self.report_path = os.path.join(manifest.reports_folder, 'prop_dir') | ||
|
|
||
| @unittest.skip("known issue") | ||
| @pytest.mark.skip("known issue") |
There was a problem hiding this comment.
The pytest.mark.skip decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skip(reason='known issue').
| @pytest.mark.skip("known issue") | |
| @pytest.mark.skip(reason="known issue") |
No description provided.