1+ """
2+ Configuración de pytest para AdataVision
3+ """
4+ import pytest
5+ import os
6+ import sys
7+
8+ def pytest_configure (config ):
9+ """Configuración de pytest"""
10+ # Agregar marcadores personalizados
11+ config .addinivalue_line (
12+ "markers" , "gui: marks tests that require GUI (skip in CI)"
13+ )
14+ config .addinivalue_line (
15+ "markers" , "slow: marks tests as slow (deselect with '-m \" not slow\" ')"
16+ )
17+ config .addinivalue_line (
18+ "markers" , "integration: marks tests as integration tests"
19+ )
20+ config .addinivalue_line (
21+ "markers" , "unit: marks tests as unit tests"
22+ )
23+
24+ def pytest_collection_modifyitems (config , items ):
25+ """Modificar items de colección de tests"""
26+ # Saltar tests de GUI en CI
27+ if os .environ .get ('CI' ) == 'true' :
28+ skip_gui = pytest .mark .skip (reason = "Skip GUI tests in CI environment" )
29+ for item in items :
30+ if "gui" in item .keywords :
31+ item .add_marker (skip_gui )
32+
33+ @pytest .fixture (scope = "session" )
34+ def qapp ():
35+ """Fixture para QApplication en tests"""
36+ if os .environ .get ('CI' ) == 'true' :
37+ # En CI, usar modo offscreen
38+ os .environ ['QT_QPA_PLATFORM' ] = 'offscreen'
39+
40+ try :
41+ from PySide6 .QtWidgets import QApplication
42+ app = QApplication .instance ()
43+ if app is None :
44+ app = QApplication ([])
45+ yield app
46+ except ImportError :
47+ pytest .skip ("PySide6 not available" )
48+ except Exception as e :
49+ pytest .skip (f"QApplication not available: { e } " )
50+
51+ @pytest .fixture
52+ def temp_file ():
53+ """Fixture para archivos temporales"""
54+ import tempfile
55+ import os
56+
57+ with tempfile .NamedTemporaryFile (delete = False ) as f :
58+ temp_path = f .name
59+
60+ yield temp_path
61+
62+ # Limpiar
63+ try :
64+ os .unlink (temp_path )
65+ except OSError :
66+ pass
0 commit comments