Skip to content

Commit df71ccc

Browse files
committed
refactor(coda): drop importlib boilerplate from test bootstrap
The integration root is already on sys.path via the workspace-level conftest.py (which patches Integration.load to find config.json). The redundant importlib.util.spec_from_file_location dance and the tests/conftest.py sys.path tweak are no longer needed. Matches the simpler bootstrap pattern used by google-sheets in PR #289.
1 parent 0213f43 commit df71ccc

3 files changed

Lines changed: 9 additions & 35 deletions

File tree

coda/tests/conftest.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

coda/tests/test_coda_integration.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,12 @@
1212
"""
1313

1414
import os
15-
import sys
16-
import importlib.util
1715

18-
_parent = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
19-
_deps = os.path.abspath(os.path.join(os.path.dirname(__file__), "../dependencies"))
20-
sys.path.insert(0, _parent)
21-
sys.path.insert(0, _deps)
16+
import pytest
17+
from unittest.mock import AsyncMock, MagicMock
18+
from autohive_integrations_sdk import FetchResponse
2219

23-
import pytest # noqa: E402
24-
from unittest.mock import AsyncMock, MagicMock # noqa: E402
25-
from autohive_integrations_sdk import FetchResponse # noqa: E402
26-
27-
_spec = importlib.util.spec_from_file_location("coda_mod_integration", os.path.join(_parent, "coda.py"))
28-
_mod = importlib.util.module_from_spec(_spec)
29-
_spec.loader.exec_module(_mod)
30-
31-
coda = _mod.coda
20+
from coda.coda import coda
3221

3322
pytestmark = pytest.mark.integration
3423

coda/tests/test_coda_unit.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
import os
2-
import sys
3-
import importlib.util
1+
import pytest
2+
from unittest.mock import AsyncMock, MagicMock
3+
from autohive_integrations_sdk import FetchResponse, ResultType
44

5-
_parent = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
6-
sys.path.insert(0, _parent)
7-
8-
import pytest # noqa: E402
9-
from unittest.mock import AsyncMock, MagicMock # noqa: E402
10-
from autohive_integrations_sdk import FetchResponse, ResultType # noqa: E402
11-
12-
_spec = importlib.util.spec_from_file_location("coda_mod", os.path.join(_parent, "coda.py"))
13-
_mod = importlib.util.module_from_spec(_spec)
14-
_spec.loader.exec_module(_mod)
15-
sys.modules["coda_mod"] = _mod
16-
17-
coda = _mod.coda
5+
from coda.coda import coda
186

197
pytestmark = pytest.mark.unit
208

@@ -704,3 +692,4 @@ async def test_error(self, mock_context):
704692
)
705693

706694
assert result.type == ResultType.ACTION_ERROR
695+

0 commit comments

Comments
 (0)