Skip to content

Commit 5b2e3af

Browse files
committed
[PLT-0] Fix tests package import under console-script pytest
CI runs pytest as a console script, which never puts the project directory on sys.path, so the new 'from tests.embedding_cleanup import ...' failed at conftest load (ModuleNotFoundError: No module named 'tests'). Local runs masked this because 'python -m pytest' adds the cwd. Insert the project directory in conftest before the tests.* import; verified against all three lanes with the console-script invocation.
1 parent 93d03c2 commit 5b2e3af

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

libs/labelbox/tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import os
3+
import pathlib
34
import re
5+
import sys
46
import time
57
import uuid
68
from datetime import datetime
@@ -32,7 +34,15 @@
3234
from labelbox.schema.ontology import Ontology
3335
from labelbox.schema.project import Project
3436
from labelbox.schema.quality_mode import QualityMode
35-
from tests.embedding_cleanup import (
37+
38+
# CI invokes pytest as a console script, which (unlike `python -m pytest`)
39+
# never puts the project directory on sys.path, so `tests.*` is not
40+
# importable when this conftest loads. Insert it deterministically.
41+
_PROJECT_DIR = str(pathlib.Path(__file__).resolve().parent.parent)
42+
if _PROJECT_DIR not in sys.path:
43+
sys.path.insert(0, _PROJECT_DIR)
44+
45+
from tests.embedding_cleanup import ( # noqa: E402 (needs the sys.path insert above)
3646
build_embedding_name,
3747
create_embedding_with_heal,
3848
)

0 commit comments

Comments
 (0)