diff --git a/test/lib/hooks/telemetry/detectEnvironment.test.ts b/test/lib/hooks/telemetry/detectEnvironment.test.ts index ac0ddb408..b7c88de0a 100644 --- a/test/lib/hooks/telemetry/detectEnvironment.test.ts +++ b/test/lib/hooks/telemetry/detectEnvironment.test.ts @@ -17,12 +17,17 @@ describe('detectAiAgent', () => { 'OPENCLAW_SHELL', ]; - afterEach(() => { + beforeEach(() => { + // The suite itself may run inside one of these agents, so clear the vars before each test for (const key of agentEnvVars) { - delete process.env[key]; + vi.stubEnv(key, undefined); } }); + afterEach(() => { + vi.unstubAllEnvs(); + }); + test('returns undefined when no agent env vars are set', () => { expect(detectAiAgent()).toBeUndefined(); }); diff --git a/test/local/__fixtures__/python_support.test.ts b/test/local/__fixtures__/python_support.test.ts index beb80f2f5..f127e5ced 100644 --- a/test/local/__fixtures__/python_support.test.ts +++ b/test/local/__fixtures__/python_support.test.ts @@ -12,7 +12,7 @@ const actorName = 'my-python-actor'; const PYTHON_START_TEMPLATE_ID = 'python-start'; const { beforeAllCalls, afterAllCalls, joinPath, tmpPath, toggleCwdBetweenFullAndParentPath } = useTempPath(actorName, { create: true, - remove: false, + remove: true, cwd: true, cwdParent: true, }); @@ -34,6 +34,11 @@ describe('[python] Python support', () => { }); it('should work', { timeout: TEST_TIMEOUT }, async () => { + if (existsSync(tmpPath)) { + // Remove the tmp path before detecting the runtime, so a leftover .venv is not picked up + await rm(tmpPath, { recursive: true, force: true }); + } + const runtime = await usePythonRuntime({ cwd: tmpPath, force: true }); const pythonVersion = runtime.map((r) => r.version).unwrapOr(undefined); @@ -44,11 +49,6 @@ describe('[python] Python support', () => { return; } - if (existsSync(tmpPath)) { - // Remove the tmp path if it exists - await rm(tmpPath, { recursive: true, force: true }); - } - await testRunCommand(CreateCommand, { args_actorName: actorName, flags_template: PYTHON_START_TEMPLATE_ID,