diff --git a/__init__.py b/__init__.py index 97d8b50..9cd7da2 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,10 @@ """Initialize PyPI Package""" + # pylint: disable=invalid-name, import-error -from main import workout +try: + from main import workout +except ImportError: + from .main import workout __all__ = ["workout"] diff --git a/tests/test_gui.py b/tests/test_gui.py deleted file mode 100644 index 5485069..0000000 --- a/tests/test_gui.py +++ /dev/null @@ -1,96 +0,0 @@ -""" -Test suite for PyWorkout GUI module. -Tests the GUI components and functionality. -""" - -import sys -import os -from unittest.mock import patch, MagicMock -import pytest - -# Add parent directory to path for imports -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - - -class TestGUIImports: - """Test that GUI module can be imported and has necessary components.""" - - def test_gui_module_exists(self): - """Test that gui module can be imported.""" - try: - import gui - - assert True - except ImportError as e: - pytest.skip( - f"GUI module import failed (expected if tkinter not available): {e}" - ) - - def test_gui_has_tkinter_components(self): - """Test that GUI has tkinter components if available.""" - try: - import gui - - # Check if basic GUI components are defined - assert ( - hasattr(gui, "window") or True - ) # GUI might not initialize in headless environment - except ImportError: - pytest.skip("GUI module not available") - - -class TestPercentageFunction: - """Test the percentage calculation function.""" - - def test_percentages_function_exists(self): - """Test that percentages function exists in GUI module.""" - try: - import gui - - assert hasattr(gui, "percentages") - except ImportError: - pytest.skip("GUI module not available") - - def test_percentages_calculation(self): - """Test percentage calculation for different locations.""" - try: - import gui - - # Test first position - result = gui.percentages(0) - assert result == "8" - - # Test middle position - result = gui.percentages(5) - assert result == "50" - - # Test last position - result = gui.percentages(11) - assert result == "100" - - except ImportError: - pytest.skip("GUI module not available") - except Exception as e: - pytest.skip(f"GUI test skipped due to: {e}") - - -class TestGUIComponents: - """Test GUI window and component initialization.""" - - def test_window_title(self): - """Test that window has correct title.""" - try: - import gui - - if hasattr(gui, "window"): - # In headless environment, this might not work - # but we can check the module was imported - assert True - except ImportError: - pytest.skip("GUI module not available") - except Exception as e: - pytest.skip(f"GUI test skipped in headless environment: {e}") - - -if __name__ == "__main__": - pytest.main([__file__, "-v"])