Skip to content

Commit fb4331b

Browse files
ctruedenclaude
andcommitted
Ensure built appose environments use newest appose
Normally, when building an environment in-line with uv -- i.e. with include rather than a separate environment file -- the most recent *release* version of appose will be used. But in case there have been changes to the appose.python_worker here, we'd like to be running our tests against this same *dev* version of appose, rather than the older release version. One way of encouraging that without making the appose builder logic more complex is to inject the local appose source tree into the built environment via a PYTHONPATH environment variable override. Then this source tree will take precedence over the installed appose. This commit adds a new source_override() helper function to test_base so that tests needing it can do this with a single function call. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 736ecb5 commit fb4331b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_base.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from __future__ import annotations
88

99
import os
10+
from pathlib import Path
1011

1112
from appose import Environment
1213
from appose.service import ResponseType, Task, TaskStatus
@@ -123,6 +124,25 @@ def cowsay_and_assert(env: Environment, greeting: str):
123124
assert "||----w |" in actual, "Output should contain cow legs"
124125

125126

127+
def source_override() -> dict[str, str]:
128+
"""
129+
Return a PYTHONPATH env var override pointing to the local appose source tree.
130+
131+
When appose is installed from source (editable install), worker processes in
132+
built environments would otherwise use their own PyPI-installed copy of appose.
133+
Passing this dict to builder.env() ensures workers load the same python_worker.py
134+
that the test runner is using.
135+
136+
Returns an empty dict when appose is installed from PyPI (non-editable), so it
137+
is safe to call unconditionally.
138+
"""
139+
import appose
140+
141+
if "site-packages" not in Path(appose.__file__).parts:
142+
return {"PYTHONPATH": str(Path(appose.__file__).parent.parent)}
143+
return {}
144+
145+
126146
def maybe_debug(service):
127147
"""
128148
Enable debug output if DEBUG or appose.debug is set.

0 commit comments

Comments
 (0)