Skip to content

Commit 6951a8d

Browse files
mattstaclaude
andcommitted
Gate live-wire tests behind live marker, skip by default
``tests/test_requests.py`` connects to a real TWS / IB Gateway on ``127.0.0.1:7497`` to exercise the request error path and the account-summary flow. Running it by default in ``make test`` is both dangerous (real ``whatIfOrder`` against whatever account the local gateway is logged into) and useless (every CI runner and any dev without TWS hits ``ConnectionRefusedError``). Add the standard pytest opt-in pattern: * ``[tool.pytest.ini_options]`` registers the ``live`` marker and sets ``addopts = "-m 'not live'"`` so the default ``pytest`` invocation deselects the live tests. * ``tests/test_requests.py`` carries ``pytest.mark.live`` (alongside the existing ``pytest.mark.asyncio``). * To run the live tests against a connected TWS / Gateway: ``pytest -m live`` (or ``pytest -m 'live or not live'`` for both). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9d29734 commit 6951a8d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,16 @@ check_untyped_defs = true
110110

111111

112112
[tool.pytest.ini_options]
113-
asyncio_mode="auto"
113+
asyncio_mode = "auto"
114+
# ``live`` tests require a running TWS / IB Gateway on
115+
# 127.0.0.1:7497. They are dangerous (real orders) and useless (no
116+
# server) by default, so the default ``addopts`` deselects them.
117+
# Opt in with ``pytest -m live`` or ``pytest -m 'live or not live'``
118+
# to include them.
119+
addopts = "-m 'not live'"
120+
markers = [
121+
"live: requires a running TWS / IB Gateway on 127.0.0.1:7497 (deselected by default)",
122+
]
114123

115124

116125
[build-system]

tests/test_requests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import ib_async as ibi
44

5-
pytestmark = pytest.mark.asyncio
5+
# Live: requires a running TWS / IB Gateway on 127.0.0.1:7497.
6+
# Skipped by default. Opt in with ``pytest -m live``.
7+
pytestmark = [pytest.mark.asyncio, pytest.mark.live]
68

79

810
async def test_request_error_raised(ib):

0 commit comments

Comments
 (0)