Repository: dr-prodigy/python-holidays

Issue:
DeprecationWarning upon "import holidays" in version 0.17
The implementation of deprecating the Swaziland calendar contains a bug. Just importing the holidays package is enough to fire the `DeprecationWarning`.

**Steps to reproduce (in bash):**

```bash
# Setup
python -m venv demo
source demo/bin/activate
pip install --upgrade pip

# Bad version
pip install holidays==0.17

# Expose bug
python -W error::DeprecationWarning -c 'import holidays'

# Workoround
pip uninstall -y holidays
pip install holidays!=0.17
python -W error::DeprecationWarning -c 'import holidays'

# Cleanup
deactivate
rm -rf demo
```

**Expected behavior:**

The `DeprecationWarning` should only fire when the user constructs an instance of the `Swaziland` or a subclass.


Discussion:

Patch:
diff --git a/holidays/countries/eswatini.py b/holidays/countries/eswatini.py
index 00ca75bf..798bd495 100644
--- a/holidays/countries/eswatini.py
+++ b/holidays/countries/eswatini.py
@@ -80,11 +80,13 @@ class Eswatini(HolidayBase):
 
 
 class Swaziland(Eswatini):
-    warnings.warn(
-        "Swaziland is deprecated, use Eswatini instead.",
-        DeprecationWarning,
-    )
-    pass
+    def __init__(self, *args, **kwargs) -> None:
+        warnings.warn(
+            "Swaziland is deprecated, use Eswatini instead.",
+            DeprecationWarning,
+        )
+
+        super().__init__(*args, **kwargs)
 
 
 class SZ(Eswatini):


Test patch:
diff --git a/test/countries/test_eswatini.py b/test/countries/test_eswatini.py
index 29d3d34e..038c2b92 100644
--- a/test/countries/test_eswatini.py
+++ b/test/countries/test_eswatini.py
@@ -10,6 +10,7 @@
 #  License: MIT (see LICENSE file)
 
 import unittest
+import warnings
 from datetime import date
 
 import holidays
@@ -59,3 +60,12 @@ class TestEswatini(unittest.TestCase):
         self.assertIn(date(2021, 4, 26), self.holidays)
         self.assertIn(date(2021, 12, 27), self.holidays)
         self.assertIn(date(2023, 1, 2), self.holidays)
+
+    def test_swaziland_deprecation_warning(self):
+        warnings.simplefilter("default")
+        with self.assertWarns(Warning):
+            holidays.Swaziland()
+
+        warnings.simplefilter("error")
+        with self.assertRaises(Warning):
+            holidays.Swaziland()