Skip to content

Commit f1fd6b0

Browse files
committed
Fix Tello test failure on CI by checking Tello identity instead of flag
Change TelloSource.__init__ to check `Tello is None` instead of `not TELLO_AVAILABLE`. This resolves a CI-specific failure where the class-level @patch("src.tello_source.TELLO_AVAILABLE", True) decorator wasn't consistently applying before the first test method ran (test_commands_disabled_by_config, alphabetically first). The new check works naturally with @patch("src.tello_source.Tello") since the mock replaces Tello with a MagicMock (not None), so the guard passes without needing a separate TELLO_AVAILABLE patch. Removed all @patch("src.tello_source.TELLO_AVAILABLE", True) decorators from tests that already patch Tello. Updated test_creation_without_djitellopy to patch Tello to None instead. https://claude.ai/code/session_012XY2M4e4QuJnMcVhA2Zicx
1 parent 154826e commit f1fd6b0

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

src/tello_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, config: Config):
3535
"""
3636
super().__init__()
3737

38-
if not TELLO_AVAILABLE:
38+
if Tello is None:
3939
raise ImportError(
4040
"djitellopy is required for Tello support. Install with: pip install djitellopy"
4141
)

tests/test_tello_interface.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_import_without_djitellopy(self):
4040
pass # Expected if djitellopy truly not available
4141

4242

43-
@patch("src.tello_source.TELLO_AVAILABLE", True)
4443
@patch("src.tello_source.Tello")
4544
class TestTelloSource(unittest.TestCase):
4645
"""Test TelloSource class with mocked Tello."""
@@ -397,7 +396,6 @@ def test_release_while_flying(self, mock_tello_class):
397396
class TestTelloEdgeCases(unittest.TestCase):
398397
"""Test edge cases for Tello source."""
399398

400-
@patch("src.tello_source.TELLO_AVAILABLE", True)
401399
@patch("src.tello_source.Tello")
402400
def test_read_without_opening(self, mock_tello_class):
403401
"""Test reading before opening connection."""
@@ -411,7 +409,6 @@ def test_read_without_opening(self, mock_tello_class):
411409
self.assertFalse(success)
412410
self.assertIsNone(frame)
413411

414-
@patch("src.tello_source.TELLO_AVAILABLE", True)
415412
@patch("src.tello_source.Tello")
416413
def test_commands_without_opening(self, mock_tello_class):
417414
"""Test sending commands before opening."""
@@ -426,7 +423,7 @@ def test_commands_without_opening(self, mock_tello_class):
426423

427424
mock_tello_class.assert_not_called()
428425

429-
@patch("src.tello_source.TELLO_AVAILABLE", False)
426+
@patch("src.tello_source.Tello", None)
430427
def test_creation_without_djitellopy(self):
431428
"""Test that creation fails gracefully without djitellopy."""
432429
from src.tello_source import TelloSource
@@ -437,7 +434,6 @@ def test_creation_without_djitellopy(self):
437434
TelloSource(config)
438435

439436

440-
@patch("src.tello_source.TELLO_AVAILABLE", True)
441437
@patch("src.tello_source.Tello")
442438
class TestTelloSafetyFeatures(unittest.TestCase):
443439
"""Test safety features for Tello source."""

0 commit comments

Comments
 (0)