Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,960 Bytes
8f383ed 4780d8d 76070ab b05124c 4780d8d b05124c 6241f9d b52343d 6241f9d 76070ab b05124c 4780d8d 8f383ed 4780d8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
"""Pytest configuration and fixtures."""
import sys
from unittest.mock import MagicMock
# Create mock component that tracks visible attribute
class MockComponent(MagicMock):
"""Mock Gradio component that tracks visible attribute."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.visible = kwargs.get('visible', True)
# Create mock for gradio with Error class
class GradioMock(MagicMock):
"""Mock for gradio that supports Error and Warning classes."""
Error = Exception
@staticmethod
def Warning(msg):
"""Mock Warning that accepts a message."""
return None
@staticmethod
def DownloadButton(*args, **kwargs):
"""Mock DownloadButton that tracks visible attribute."""
return MockComponent(*args, **kwargs)
@staticmethod
def DataFrame(*args, **kwargs):
"""Mock DataFrame that tracks visible attribute."""
return MockComponent(*args, **kwargs)
@staticmethod
def Label(*args, **kwargs):
"""Mock Label that tracks visible attribute."""
return MockComponent(*args, **kwargs)
@staticmethod
def Textbox(*args, **kwargs):
"""Mock Textbox that tracks visible attribute."""
return MockComponent(*args, **kwargs)
Request = MagicMock
Progress = MagicMock
# Mock heavy dependencies before any imports
# This is necessary to allow tests to run without full environment setup
sys.modules["mussel"] = MagicMock()
sys.modules["mussel.models"] = MagicMock()
sys.modules["mussel.utils"] = MagicMock()
sys.modules["mussel.utils.segment"] = MagicMock()
sys.modules["mussel.cli"] = MagicMock()
sys.modules["mussel.cli.tessellate"] = MagicMock()
sys.modules["gradio"] = GradioMock()
sys.modules["huggingface_hub"] = MagicMock()
sys.modules["loguru"] = MagicMock()
# Import fixtures from test_fixtures.py to make them available to all tests
pytest_plugins = ["tests.test_fixtures"]
|