Skip to content

Comments

Remove unittest#72

Closed
kfrey-idm wants to merge 3 commits intoEMOD-Hub:mainfrom
kfrey-idm:kfrey_unittest
Closed

Remove unittest#72
kfrey-idm wants to merge 3 commits intoEMOD-Hub:mainfrom
kfrey-idm:kfrey_unittest

Conversation

@kfrey-idm
Copy link
Member

No description provided.

@kfrey-idm kfrey-idm requested a review from Copilot February 5, 2026 19:22
@kfrey-idm kfrey-idm self-assigned this Feb 5, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 unittest statements from all test files
  • Converted test classes from inheriting unittest.TestCase to plain classes
  • Replaced unittest decorators with pytest equivalents (@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
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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']}.

Copilot uses AI. Check for mistakes.

@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")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
return

@unittest.skipUnless(support.SNAPPY_SUPPORT, "No Snappy [de]compression support.")
@pytest.mark.skipif(not support.SNAPPY_SUPPORT, "No Snappy [de]compression support.")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.').

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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').

Copilot uses AI. Check for mistakes.


@unittest.skipIf(skip_tests, "Skipping old tests to focus on V6")
@pytest.mark.skipif(skip_tests, "Skipping old tests to focus on V6")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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').

Copilot uses AI. Check for mistakes.
@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):
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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):.

Suggested change
with self.assertRaises(UserWarning):
with pytest.raises(UserWarning):

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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').

Copilot uses AI. Check for mistakes.
os.remove(tmpfile)

@unittest.skipIf(thisplatform.startswith("win"), "Not valid on Windows")
@pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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').

Copilot uses AI. Check for mistakes.
print("Child method - Done..")

@unittest.skipIf(thisplatform.startswith("win"), "Not valid on Windows")
@pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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').

Suggested change
@pytest.mark.skipif(thisplatform.startswith("win"), "Not valid on Windows")
@pytest.mark.skipif(thisplatform.startswith("win"), reason="Not valid on Windows")

Copilot uses AI. Check for mistakes.
self.report_path = os.path.join(manifest.reports_folder, 'prop_dir')

@unittest.skip("known issue")
@pytest.mark.skip("known issue")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The pytest.mark.skip decorator requires the reason parameter to be passed as a keyword argument. Change to @pytest.mark.skip(reason='known issue').

Suggested change
@pytest.mark.skip("known issue")
@pytest.mark.skip(reason="known issue")

Copilot uses AI. Check for mistakes.
@kfrey-idm kfrey-idm closed this Feb 5, 2026
@kfrey-idm kfrey-idm deleted the kfrey_unittest branch February 12, 2026 18:22
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.

1 participant