Skip to content

Commit e3a0918

Browse files
committed
pre-commit
1 parent 0a35d0b commit e3a0918

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

.github/workflows/test-metatrader5-integration.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ jobs:
3333
exit 1
3434
}
3535
shell: pwsh
36-
36+
3737
- name: Launch MT5
3838
shell: pwsh
3939
run: |
4040
$mt5Path = Resolve-Path "C:\Program Files\MetaTrader 5\terminal64.exe"
41-
41+
4242
# Launch with diagnostics
4343
Start-Process $mt5Path -ArgumentList @(
4444
"/portable",
@@ -73,4 +73,4 @@ jobs:
7373
MT5_SERVER: "'MetaQuotes-Demo'"
7474
MT5_PATH: "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
7575
run: |
76-
python tests/integration/test_mt5_connection.py
76+
python tests/integration/test_mt5_connection.py
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
import MetaTrader5 as mt5
2-
import time
3-
import sys
4-
import os
1+
"""Integration test for MetaTrader5 connection.
2+
3+
This module tests the ability to establish a connection with MT5 platform.
4+
"""
5+
56
import logging
7+
import os
8+
import time
9+
10+
import MetaTrader5 as mt5 # noqa: N813
611

712
# Configure logging
813
logger = logging.getLogger(__name__)
914
logger.setLevel(logging.INFO)
1015

1116

12-
print('Testing MT5 initialization...')
17+
logger.info("Testing MT5 initialization...")
1318

1419
success = False
1520
for attempt in range(10):
16-
if mt5.initialize(login=int(os.getenv('MT5_LOGIN')),
17-
password=os.getenv('MT5_PASSWORD'),
18-
server=os.getenv('MT5_SERVER'),
19-
path=os.getenv('MT5_PATH')):
20-
print('MT5 initialized successfully')
21+
if mt5.initialize(
22+
login=os.getenv("MT5_LOGIN"),
23+
password=os.getenv("MT5_PASSWORD"),
24+
server=os.getenv("MT5_SERVER"),
25+
path=os.getenv("MT5_PATH"),
26+
):
27+
logger.info("MT5 initialized successfully")
2128
mt5.shutdown()
2229
success = True
2330
break
2431
else:
25-
print(f'Attempt {attempt+1}: Not ready yet, sleeping...')
32+
logger.info(f"Attempt {attempt+1}: Not ready yet, sleeping...")
2633
time.sleep(5)
2734

2835
if not success:
29-
print('Failed to initialize MT5 after waiting.')
30-
sys.exit(1)
36+
logger.info("Failed to initialize MT5 after waiting.")
37+
mt5.shutdown()

0 commit comments

Comments
 (0)