Skip to content

Commit

Permalink
Update tests: use assertIsInstance (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r authored Mar 20, 2024
1 parent e236b40 commit f08962c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
16 changes: 8 additions & 8 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def test_countries_imports(self):
self.assertIsNotNone(loader_cls, entity)
self.assertIsNotNone(module_cls, entity)
self.assertEqual(countries_cls, module_cls)
self.assertTrue(isinstance(loader_cls, registry.EntityLoader))
self.assertTrue(isinstance(loader_cls(), countries_cls))
self.assertTrue(isinstance(loader_cls(), module_cls))
self.assertIsInstance(loader_cls, registry.EntityLoader)
self.assertIsInstance(loader_cls(), countries_cls)
self.assertIsInstance(loader_cls(), module_cls)

loader_entities.add(loader_cls.__name__)

Expand Down Expand Up @@ -82,9 +82,9 @@ def test_financial_imports(self):
self.assertIsNotNone(loader_cls, entity)
self.assertIsNotNone(module_cls, entity)
self.assertEqual(financial_cls, module_cls)
self.assertTrue(isinstance(loader_cls, registry.EntityLoader))
self.assertTrue(isinstance(loader_cls(), financial_cls))
self.assertTrue(isinstance(loader_cls(), module_cls))
self.assertIsInstance(loader_cls, registry.EntityLoader)
self.assertIsInstance(loader_cls(), financial_cls)
self.assertIsInstance(loader_cls(), module_cls)

loader_entities.add(loader_cls.__name__)

Expand Down Expand Up @@ -115,7 +115,7 @@ class SubClass(parent):
return SubClass()

for cls in (holidays.UnitedStates, holidays.US, holidays.USA):
self.assertTrue(isinstance(cls, holidays.registry.EntityLoader))
self.assertIsInstance(cls, holidays.registry.EntityLoader)
with self.assertRaises(TypeError):
create_instance(cls)

Expand All @@ -124,4 +124,4 @@ class SubClass(parent):
holidays.countries.US,
holidays.countries.USA,
):
self.assertTrue(isinstance(create_instance(cls), holidays.countries.UnitedStates))
self.assertIsInstance(create_instance(cls), holidays.countries.UnitedStates)
9 changes: 3 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ def assertLocalizedEntities(self, localized_entities, supported_entities):
)

if expected_languages:
self.assertTrue(
isinstance(expected_languages, list),
entity_code,
)
self.assertIsInstance(expected_languages, list, entity_code)
self.assertIn(
entity.default_language,
expected_languages,
Expand Down Expand Up @@ -212,7 +209,7 @@ def test_list_supported_countries(self):

us_subdivisions = supported_countries["US"]
self.assertIn("CA", us_subdivisions)
self.assertTrue(isinstance(us_subdivisions, list))
self.assertIsInstance(us_subdivisions, list)

countries_files = [
path for path in Path("holidays/countries").glob("*.py") if path.stem != "__init__"
Expand All @@ -229,7 +226,7 @@ def test_list_supported_financial(self):
self.assertIn("NYSE", supported_financial)

nyse = supported_financial["NYSE"]
self.assertTrue(isinstance(nyse, list))
self.assertIsInstance(nyse, list)

financial_files = [
path for path in Path("holidays/financial").glob("*.py") if path.stem != "__init__"
Expand Down

0 comments on commit f08962c

Please sign in to comment.