File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 25
25
TEST_FEE = 1.5
26
26
27
27
28
+ def is_headless () -> bool :
29
+ """Check if running in headless mode."""
30
+ return os .environ .get ("HEADLESS_MODE" , "false" ).lower () == "true"
31
+
32
+
28
33
@pytest .fixture (scope = "module" , autouse = True )
29
34
def setup_teardown () -> Generator [None , None , None ]:
30
35
"""Set up and tear down MetaTrader5 connection for the test module."""
36
+ if is_headless ():
37
+ logger .info ("Running in headless mode - skipping MT5 initialization" )
38
+ yield
39
+ return
40
+
31
41
init_result = Mt5 .initialize ()
32
42
33
43
if not init_result :
@@ -487,3 +497,10 @@ def test_close_position(trade: Trade) -> None:
487
497
except Exception as e :
488
498
logger .exception ("Error during position test" )
489
499
raise
500
+
501
+
502
+ @pytest .fixture (autouse = True )
503
+ def skip_real_trading_in_headless (request ) -> None :
504
+ """Skip real trading tests in headless mode."""
505
+ if is_headless () and request .node .get_closest_marker ("real_trading" ):
506
+ pytest .skip ("Skipping real trading test in headless mode" )
You can’t perform that action at this time.
0 commit comments