mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-24 07:38:14 +00:00
Address PR feedback: Add deprecation warning and expand test coverage
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -5,6 +5,15 @@ This module allows older code that imports from `crewai.telemtry` (misspelled)
|
|||||||
to continue working by re-exporting the Telemetry class from the correctly
|
to continue working by re-exporting the Telemetry class from the correctly
|
||||||
spelled `crewai.telemetry` module.
|
spelled `crewai.telemetry` module.
|
||||||
"""
|
"""
|
||||||
|
import warnings
|
||||||
|
|
||||||
from crewai.telemetry import Telemetry
|
from crewai.telemetry import Telemetry
|
||||||
|
|
||||||
|
warnings.warn(
|
||||||
|
"Importing from 'crewai.telemtry' is deprecated due to spelling issues. "
|
||||||
|
"Please use 'from crewai.telemetry import Telemetry' instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2
|
||||||
|
)
|
||||||
|
|
||||||
__all__ = ["Telemetry"]
|
__all__ = ["Telemetry"]
|
||||||
|
|||||||
@@ -1,10 +1,30 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
class BackwardCompatibilityTest(unittest.TestCase):
|
class BackwardCompatibilityTest(unittest.TestCase):
|
||||||
def test_telemtry_typo_compatibility(self):
|
def test_telemtry_typo_compatibility(self):
|
||||||
"""Test that the backward compatibility for the telemtry typo works."""
|
"""Test that the backward compatibility for the telemtry typo works."""
|
||||||
from crewai.telemtry import Telemetry as MisspelledTelemetry
|
|
||||||
from crewai.telemetry import Telemetry
|
from crewai.telemetry import Telemetry
|
||||||
|
from crewai.telemtry import Telemetry as MisspelledTelemetry
|
||||||
|
|
||||||
self.assertIs(MisspelledTelemetry, Telemetry)
|
self.assertIs(MisspelledTelemetry, Telemetry)
|
||||||
|
|
||||||
|
def test_functionality_preservation(self):
|
||||||
|
"""Test that the re-exported Telemetry class preserves all functionality."""
|
||||||
|
from crewai.telemetry import Telemetry
|
||||||
|
from crewai.telemtry import Telemetry as MisspelledTelemetry
|
||||||
|
|
||||||
|
self.assertEqual(dir(MisspelledTelemetry), dir(Telemetry))
|
||||||
|
|
||||||
|
def test_deprecation_warning(self):
|
||||||
|
"""Test that importing from the misspelled module raises a deprecation warning."""
|
||||||
|
with warnings.catch_warnings(record=True) as w:
|
||||||
|
warnings.simplefilter("always")
|
||||||
|
|
||||||
|
from crewai.telemtry import Telemetry # noqa: F401
|
||||||
|
|
||||||
|
self.assertEqual(len(w), 1)
|
||||||
|
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
|
||||||
|
self.assertIn("crewai.telemtry", str(w[0].message))
|
||||||
|
self.assertIn("crewai.telemetry", str(w[0].message))
|
||||||
|
|||||||
Reference in New Issue
Block a user