File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2525TEST_FEE = 1.5
2626
2727
28+ def is_headless () -> bool :
29+ """Check if running in headless mode."""
30+ return os .environ .get ("HEADLESS_MODE" , "false" ).lower () == "true"
31+
32+
2833@pytest .fixture (scope = "module" , autouse = True )
2934def setup_teardown () -> Generator [None , None , None ]:
3035 """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+
3141 init_result = Mt5 .initialize ()
3242
3343 if not init_result :
@@ -487,3 +497,10 @@ def test_close_position(trade: Trade) -> None:
487497 except Exception as e :
488498 logger .exception ("Error during position test" )
489499 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