From 4e8eb7310ce7c95e5a213361df0422fa3828e000 Mon Sep 17 00:00:00 2001 From: Jandres Date: Sun, 30 Nov 2025 09:37:49 -0400 Subject: [PATCH] refactor: reorganizar proyecto con estructura src/ y tests/ --- .github/workflows/ci.yml | 4 ++-- requirements.txt | 2 ++ src/__init__.py | 7 +++++++ calculator.py => src/calculator.py | 0 main.py => src/cli.py | 3 +-- gui.py => src/gui.py | 10 +++++++++- tests/__init__.py | 4 ++++ conftest.py => tests/conftest.py | 5 +++++ test_calculator.py => tests/test_calculator.py | 2 +- test_gui_calculator.py => tests/test_gui.py | 2 +- 10 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 requirements.txt create mode 100644 src/__init__.py rename calculator.py => src/calculator.py (100%) rename main.py => src/cli.py (96%) rename gui.py => src/gui.py (96%) create mode 100644 tests/__init__.py rename conftest.py => tests/conftest.py (90%) rename test_calculator.py => tests/test_calculator.py (94%) rename test_gui_calculator.py => tests/test_gui.py (99%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4237c6..f903de3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest + pip install -r requirements.txt - name: Run tests - run: pytest -v + run: pytest tests/ -v diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..536e546 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# Dependencias para desarrollo y testing +pytest>=7.0.0 diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..2a61ebb --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,7 @@ +"""Paquete calculadora con GUI y CLI. + +Módulos: + calculator: Funciones matemáticas básicas + gui: Interfaz gráfica con tkinter + cli: Interfaz de línea de comandos +""" \ No newline at end of file diff --git a/calculator.py b/src/calculator.py similarity index 100% rename from calculator.py rename to src/calculator.py diff --git a/main.py b/src/cli.py similarity index 96% rename from main.py rename to src/cli.py index 4154386..6b81ed7 100644 --- a/main.py +++ b/src/cli.py @@ -1,11 +1,10 @@ -#!/usr/bin/env python3 """Archivo principal de ejemplo para el proyecto Team Practice. Demuestra cómo usar los módulos del proyecto y cómo estructurar un punto de entrada principal. """ -from calculator import add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value +from .calculator import add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value def main(): """Función principal del programa.""" diff --git a/gui.py b/src/gui.py similarity index 96% rename from gui.py rename to src/gui.py index 6ada399..536370e 100644 --- a/gui.py +++ b/src/gui.py @@ -1,5 +1,13 @@ +"""Interfaz gráfica de usuario (GUI) para la calculadora. + +Este módulo implementa una calculadora con interfaz tkinter que incluye: +- Operaciones básicas: suma, resta, multiplicación, división, potencia +- Funciones científicas: valor absoluto, máximo, mínimo +- Soporte para teclado y números negativos +- Manejo de errores con mensajes visuales +""" import tkinter as tk -from calculator import (add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value) +from .calculator import (add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value) class CalculatorGUI: def __init__(self, root): diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..96a5d7b --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,4 @@ +"""Suite de tests para Team Practice Calculator. + +Tests unitarios para los módulos calculator y gui. +""" \ No newline at end of file diff --git a/conftest.py b/tests/conftest.py similarity index 90% rename from conftest.py rename to tests/conftest.py index 2800878..e0ddbc8 100644 --- a/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,8 @@ +"""Configuración de pytest y fixtures para tests. + +Este módulo contiene fixtures y configuración compartida para todos los tests. +Incluye mocks de componentes tkinter para ejecutar tests sin interfaz gráfica. +""" import pytest import tkinter as tk diff --git a/test_calculator.py b/tests/test_calculator.py similarity index 94% rename from test_calculator.py rename to tests/test_calculator.py index 3d812e9..3ced422 100644 --- a/test_calculator.py +++ b/tests/test_calculator.py @@ -6,7 +6,7 @@ import pytest -from calculator import add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value +from src.calculator import add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value def test_add(): diff --git a/test_gui_calculator.py b/tests/test_gui.py similarity index 99% rename from test_gui_calculator.py rename to tests/test_gui.py index c2a78e6..164b1cd 100644 --- a/test_gui_calculator.py +++ b/tests/test_gui.py @@ -4,7 +4,7 @@ Para correr los tests: pytest test_gui_calculator.py -v """ import tkinter as tk -from gui import CalculatorGUI +from src.gui import CalculatorGUI # ============================================================================