Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

tests: discuss removing dotenv environment mutation during TTS collection

未关闭
#8,230 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
testing

调研方向

Read tests/test_tts.py, especially the module level load_dotenv(override=True) call and the collection time PLUGIN filtering. First reproduce the overwrite in a subprocess using a temporary .env and dummy values, then determine how provider selection and credentials should be prepared explicitly for TTS tests. Done means collect only preserves preexisting environment values while intentional TTS configuration still works.

由索引模型根据 Issue 内容生成。

描述

Problem

While auditing test import-time side effects after #8134, I noticed that tests/test_tts.py calls load_dotenv(override=True) at module scope.

At main commit 2a1c02d17cb90244dc27a8161ff4825707430665, this is at line 56:
https://github.com/livekit/agents/blob/2a1c02d17cb90244dc27a8161ff4825707430665/tests/test_tts.py#L56

Importing the module during collection can therefore replace pre-existing process environment values with values from a discovered .env, even when no test executes. Later in the same module, the PLUGIN environment variable controls parameter filtering, so preserving intentional collection-time configuration needs care.

This module already has the tts category marker. Category filtering protects --unit runs; this report concerns collection when the TTS module is selected or pytest runs without a category filter. I am not claiming the current unit gate imports it or that this causes a model download.

Verification

I parsed the test module, extracted its module-level load_dotenv(override=True) expression, and executed that expression using the real python-dotenv loader with an explicit temporary .env path. With a dummy variable initially set to from-shell and the temporary file setting it to from-dotenv, the expression overwrote the original value. No real credentials were used or inspected.

This is an isolated verification of the statement's overwrite behavior, not a full pytest collection reproduction. A regression test should exercise collection in a subprocess with a temporary .env and dummy values.

Proposed scope for discussion

Would you welcome a small follow-up that removes implicit environment mutation from importing this module and makes dotenv preparation explicit for TTS test execution?

The implementation would preserve intentional provider selection and credential setup, and verify that collect-only does not overwrite dummy environment values. Since PLUGIN is read during collection, simply moving everything into an autouse fixture would be insufficient; I would agree on the intended configuration path before implementing it.

No production behavior, changelogs, package manifests, or version files would change. I have not started an implementation and would appreciate guidance on the preferred scope.

主要语言
Python
星标
14.6k
派生
3.9k
平均合并
2 天 6 小时
30 天内合并 PR
227

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

livekit/agents 的其他 Issue

查看 livekit/agents 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。